简体   繁体   English

JSF 2 f:param 里面的 ui:repeat

[英]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>

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&param2=sss...")不幸的是,“测试”正确返回所有值,但是当我悬停链接时,没有一个参数集(“page.xhtml”而不是“page.xhtml?param1=ddd&param2=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).为了弄明白为什么我需要这个,我想获取当前页面的所有参数并添加/删除一个(点击的链接是我想要删除/添加的那个)。

to I need to generate for each link its own parameters (when param1=1,2 by default, one link has eg "param1=1,2,3" (appends 3) and the other one has "param1=1,2,4" (appends 4))我需要为每个链接生成它自己的参数(默认情况下,当 param1=1,2 时,一个链接具有例如“param1=1,2,3”(附加 3),另一个链接具有“param1=1,2, 4"(附加 4))

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. <ui:repeat/>是在构建视图树之后运行的组件标记,而<f:param/>是在视图构建期间放置在视图树中的标记处理程序。 What this means is that <f:param/> is parsed and processed before <ui:repeat/> ever makes it into the page.这意味着<f:param/><ui:repeat/>进入页面之前被解析和处理。 As a result var="parameter" is not available for use when <f:param/> needs it.因此var="parameter"<f:param/>需要时无法使用。

To fix, use the <c:forEach/> tag instead:要修复,请改用<c:forEach/>标签:

<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>

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

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