简体   繁体   English

如何计算用户的JSF会话(JSF 2.2)中的视图数?

[英]How do I count the number of views in a user's JSF session (JSF 2.2)?

I'm trying to track view usage (coming up against the default 15-count limit) but not quite sure where to get this information. 我正在尝试跟踪视图的使用情况(达到默认的15个计数限制),但不确定如何从何处获取此信息。 Is it available in FacesContext somewhere? 它在FacesContext中可用吗?

Using JSF 2.2, ICEfaces 3.3, and Omnifaces 2.2. 使用JSF 2.2,ICEfaces 3.3和Omnifaces 2.2。

It's implementation specific and only available when server side state saving is used. 它是特定于实现的,仅在使用服务器端状态保存时可用。

Based on your question history and your related OmniFaces issue report , I gather that you're using GlassFish and thus Mojarra. 根据您的问题历史记录和相关的OmniFaces问题报告 ,我认为您使用的是GlassFish,也就是Mojarra。 The physical views are available as a session attribute keyed by com.sun.faces.renderkit.ServerSideStateHelper.LogicalViewMap . 物理视图可用作由com.sun.faces.renderkit.ServerSideStateHelper.LogicalViewMap键入键的会话属性。

Thus, so: 因此,这样:

Map<String, Map<String, Object[]>> physicalViews = Faces.getSessionAttribute("com.sun.faces.renderkit.ServerSideStateHelper.LogicalViewMap");
String numberOfViews = physicalViews.size();
// ...

Note that Mojarra unintentionally swapped the meaning of "physical views" and "logical views" in both the context parameter names and the codebase. 请注意,Mojarra在上下文参数名称和代码库中无意间交换了“物理视图”和“逻辑视图”的含义。 So, the max size of the above map (the physical views) is configurable by com.sun.faces.numberOfLogicalViews and the max size of the nested map (the logical views) is configurable by com.sun.faces.numberOfViewsInSession . 因此,上述映射(物理视图)的最大大小可以通过com.sun.faces.numberOfLogicalViews配置,嵌套映射(逻辑视图)的最大大小可以通过com.sun.faces.numberOfViewsInSession配置。

See also: 也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM