简体   繁体   English

mojarra何时将命名容器添加到可选参数列表中?

[英]When does mojarra adds a naming container to the list of optional parameters?

In the source of the class AjaxBehaviorRenderer (line 260) there is a line that apparently appends the NamingContainer Id to the list of optional parameters of mojarra.ab(...) . 在类AjaxBehaviorRenderer的源代码中(第260行),有一行代码显然将NamingContainer Id附加到mojarra.ab(...)的可选参数列表中。 I've never come across it so I'm curious as to when it is used: 我从没碰过它,所以对于何时使用它感到好奇:

RenderKitUtils.appendProperty(ajaxCommand, "com.sun.faces.namingContainerId", namingContainerId, true);

line 260 260行

While working on spec issue 790 last week, which should solve ao Rendering other form by ajax causes its view state to be lost, how do I add this back? 上周在处理规格问题790时应解决的问题ao 通过ajax渲染其他形式会导致其视图状态丢失,我该如何重新添加呢? , this was explained to me by Neil Griffin, a portlet guy. ,这是Portlet专家Neil Griffin向我解释的。

It appears that portlets can have multiple JSF views rendering to the same HTML document, each with its own view state. 看起来portlet可以具有多个JSF视图,这些视图呈现到同一HTML文档,每个视图都有自己的视图状态。 In portlets, there's a special UIViewRoot instance which implements NamingContainer . 在portlet中,有一个特殊的UIViewRoot实例,该实例实现NamingContainer During regular rendering, all forms, inputs and commands will have IDs and names prefixed with the view's own client ID. 在常规渲染期间,所有表单,输入和命令都将具有以视图自身的客户端ID开头的ID和名称。 This will work fine during synchronous postbacks. 在同步回发期间,这将正常工作。 The portlet can this way identify the exact view to restore. Portlet可以这种方式标识要还原的确切视图。

However, during asynchronous postbacks, the jsf.js will create a bunch of additional ajax-specific request parameters such as javax.faces.source , javax.faces.partial.event , etc. Those request parameter names are not prefixed with the view's own client ID. 但是,在异步回发期间, jsf.js将创建一堆额外的特定于Ajax的请求参数,例如javax.faces.sourcejavax.faces.partial.event等。这些请求参数名称不带有视图自身的前缀。客户编号。 Therefore the portlet cannot associate them with a specific view. 因此,Portlet无法将它们与特定视图关联。 Hence the impl issue 3031 . 因此, 隐含问题3031

There was another problem of view state identifiers in ajax responses not being properly namespaced this way. 还有一个问题是,ajax响应中的视图状态标识符没有以这种方式正确命名。 Therefore the portlet implementation had to customize the partial response writer in the so-called "JSF bridge". 因此,portlet实现必须在所谓的“ JSF桥”中自定义部分响应编写器。 This will be taken into account during implementing spec issue 790. Instead of sniffing a "portlet environment" as in current implementation, there will be checks on UIViewRoot instanceof NamingContainer which is more flexible and portlet-independent. 在实现规范问题790时将考虑到这一点。与其像当前的实现那样嗅探“ portlet环境”,不如对UIViewRoot instanceof NamingContainer进行检查,它更加灵活且独立于portlet。 The Mojarra-specific com.sun.faces.namingContainerId will also be removed. Mojarra特定的com.sun.faces.namingContainerId也将被删除。 Instead, this value will be rendered to <partial-response id="..."> so that the jsf.js can just extract from there. 相反,该值将呈现为<partial-response id="...">以便jsf.js可以从那里提取。

All in all, not really important if you're only targeting servlet based environments. 总而言之,如果仅针对基于servlet的环境,那并不是很重要。

As per balusC comment : 根据balusC的评论:

It's only interesting for portlet based apps (not servlet based apps). 这仅对基于Portlet的应用程序(而非基于Servlet的应用程序)感兴趣。 I can't exactly explain why and what it is used for (a portlet/liferay guy might), but the portlet specific feature is called "namespaced parameters". 我无法确切解释其原因以及用途(Portlet / Liferay家伙可能会使用),但是Portlet的特定功能称为“命名空间参数”。 See https://web.liferay.com/web/meera.success/blog/-/blogs/liferay-requires-name-spaced-parameters 参见https://web.liferay.com/web/meera.success/blog/-/blogs/liferay-requires-name-spaced-parameters

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

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