JSF 2 f:ui里面的param:重复 [英] JSF 2 f:param inside of ui:repeat
问题描述
如上所述,我需要为
as the question above mentiones, i need to create "dynamic" params for a
<ui:composition>
<h:link>
<h:outputText value="link with params" />
<ui:repeat var="parameter" value="#{bean.getCurrentParameter}"> //customClass
test: #{parameter.name} #{parameter.value} //output is fine
<f:param name="#{parameter.name}" value="#{parameter.value}" />
</ui:repeat>
</h:link>
</ui:composition>
遗憾的是,test正确返回所有值,但是当我悬停链接时,没有单个参数集(page.xhtml而不是page.xhtml?param1 = ddd& param2 = sss ...)
unfortunately the "test" returns all values correctly, but when I hover the link, there is not a single parameter set ("page.xhtml" instead of "page.xhtml?param1=ddd¶m2=sss...")
要解释为什么我需要这个,我想获取当前页面的所有参数并添加/删除一个(点击的链接是我要删除/添加的链接)。
To unterstand why I need this, I want to get all parameters of the current page and add/remove one (the link clicked on is the one I want to remove/add).
我需要为每个链接生成自己的参数(当param1 = 1,2时,默认情况下,一个链接有例如param1 = 1,2,3(附加3)而另一个有param1 = 1,2,4(附加4))
to I need to generate for each link its own parameters (when param1=1,2 by default, one link has e.g. "param1=1,2,3" (appends 3) and the other one has "param1=1,2,4" (appends 4))
推荐答案
Classic taghandlers与组件标签问题。 < ui:repeat />
是在构建视图树之后运行的组件标记,而< f:param />
是在视图构建期间放置在视图树中的标记处理程序。这意味着< f:param />
在< ui:repeat /> $ c $之前被解析和处理c>永远进入页面。因此,
< f:param />
需要时, var =parameter
无法使用。
Classic taghandlers vs component tags issue. <ui:repeat/>
is a component tag that runs after the view tree has been built while <f:param/>
is a tag handler that is placed in the view tree during view build. What this means is that <f:param/>
is parsed and processed before <ui:repeat/>
ever makes it into the page. As a result var="parameter"
is not available for use when <f:param/>
needs it.
要修复此问题,请改用< c:forEach />
代码:
To fix, use the <c:forEach/>
tag instead:
<h:link>
<h:outputText value="link with params" />
<c:forEach var="parameter" items="#{bean.getCurrentParameter}">
test: #{parameter.name} #{parameter.value}
<f:param name="#{parameter.name}" value="#{parameter.value}" />
</c:forEach>
</h:link>
这篇关于JSF 2 f:ui里面的param:重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!