1

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...")

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 e.g. "param1=1,2,3" (appends 3) and the other one has "param1=1,2,4" (appends 4))

Niko
  • 1,054
  • 5
  • 25
  • 52
  • 1
    Your test looks wrong. Try to create the `` **inside** `` instead. Also, looks like your `` has a typo since it is not properly closed. – Luiggi Mendoza Oct 21 '13 at 14:44
  • Hi, I cannot put the h:link inside, because I don't want many links with one parameter, I want ONE link with many parameters. i hope the question is more clear now – Niko Oct 21 '13 at 15:16

1 Answers1

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

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>
Roger Keays
  • 3,117
  • 1
  • 31
  • 23
kolossus
  • 20,559
  • 3
  • 52
  • 104