我可以在客户端浏览器中存储哪些JSF数据 [英] What JSF data can I store in a client browser

查看:102
本文介绍了我可以在客户端浏览器中存储哪些JSF数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有兴趣将大型哈希图或列表存储到客户端吗?我需要诸如临时缓存之类的东西来存储用户会话数据.

I'm interested can I store into client side for example large hashmap or a List? I need something like a temporary cache to store user session data.

推荐答案

从理论上讲,您可以使用 JavaScript中的HTML5客户端存储.到目前为止,尚不存在可以透明地完成此工作的JSF组件.您需要自己编写所有必要的JS代码,或使用 jQuery .

In theory, you could use HTML5 client side storage in JavaScript. So far now, no JSF components exists which could do the job transparently. You'd need to write all the necessary JS code yourself or grab jQuery.

作为HTML代码生成器,所有JSF可以为您完成的工作是借助JSON库(例如

All JSF as being a HTML code generator can do for you is to print Java objects in JSON format as a JavaScript variable assignment with help of a JSON library such as Google Gson.

<h:outputScript>var data = #{bean.dataAsJSON};</h:outputScript>

getDataAsJSON()应该只返回一个已经转换的JSON字符串.

The getDataAsJSON() should just return an already converted JSON string.

这篇关于我可以在客户端浏览器中存储哪些JSF数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆