JSF - 基于回发的可变参数集
在这篇文章中,优秀的BalusC指出了使用< c:forEach>在构建时获取参数。
代码
我有一个更复杂的版本,带有基于表单另一部分的可变数量的参数(
<p:dataTable var='criterion' value='#{criteria}'
binding="#{searchBean.criteriaList}" id="#{id}">
... each row shows a criteria, which has a parameter name, an operator, and a value ...
... each row may be set or not set ...
</p:dataTable>
<p:graphicImage value="#{searchBean.lineChartImage}">
<c:forEach var="criteriaName" items="#{searchBean.usedCriteriaKeys}">
<f:param name="#{criteriaName}" value="#{searchBean.criteriaMap[criteriaName]}"/>
</c:forEach>
</p:graphicImage>
背景
我知道只要设置参数,searchBean.lineChartImage 方法就会给我正确的图表。
SearchBean 是一个RequestScope bean。
我正在使用 JSF 2.1、Tomcat 7.0.22 和 Primefaces 2.2.1。
问题
当我选择/启用一个条件(例如 param="eventDate"、operator="after"、value="2011-10-01")时,graphicImage 的参数是在早期创建的RestoreView 阶段树创建时的生命周期;我真正想要的参数集直到 UpdateModelValues 阶段才会更新。
有没有办法根据回发本身的实际结果获取 p:graphicImage 的一组参数?
In this post, the excellent BalusC pointed out the use of <c:forEach> to get the parameters at build time.
The Code
I have a more complicated version of that with a variable amount of parameters (<f:param> elements) that are based on another part of the form. The top part of the form has a DataTable of all possible "Criteria". The bottom part has a PrimeFaces graphicImage whose content is based on the selections in those criteria, including only criteria that are used.
<p:dataTable var='criterion' value='#{criteria}'
binding="#{searchBean.criteriaList}" id="#{id}">
... each row shows a criteria, which has a parameter name, an operator, and a value ...
... each row may be set or not set ...
</p:dataTable>
<p:graphicImage value="#{searchBean.lineChartImage}">
<c:forEach var="criteriaName" items="#{searchBean.usedCriteriaKeys}">
<f:param name="#{criteriaName}" value="#{searchBean.criteriaMap[criteriaName]}"/>
</c:forEach>
</p:graphicImage>
Background
I know the searchBean.lineChartImage method gives me the right chart as long as the parameters are set.
The SearchBean is a RequestScope bean.
I'm using JSF 2.1, Tomcat 7.0.22, and Primefaces 2.2.1.
The Problem
When I select/enable a criteria (e.g. param="eventDate", operator="after", value="2011-10-01"), the parameters of graphicImage are created early in the lifecycle at tree creation time in the RestoreView phase; the set of parameters that I actually want is not updated until the UpdateModelValues phase.
Is there a way to get a set of parameters for the p:graphicImage based on the actual results of the postback itself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我看到你的问题了。然而,我在视图方面并没有真正看到明确的解决方案。最好的办法是自己将这些参数附加到 bean 操作方法中
#{searchBean.lineChartImage}
后面的属性中。使用此实用程序方法,
如果存在接受
Map
或什至Map<; 的
作为值。
,则这是可能的。 String,String[]>I see your problem. I however don't really see a clear solution for in the view side. Your best bet is to append those parameters yourself to the property behind
#{searchBean.lineChartImage}
in the bean's action method.with this utility method
It would have been possible if there exist a
<f:params>
which accepts aMap<String, String>
or maybe evenMap<String, String[]>
as value.