42469

JSF 2 f:param inside of ui:repeat

Question:

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

Answer1:

Classic <a href="http://www.ninthavenue.com.au/jsf-c-foreach-vs-ui-repeat" rel="nofollow">taghandlers vs component tags</a> 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>

Recommend

  • Adding an item to a List which is DataBinded to a DataGrid
  • Calling controller method (ASP MVC3) method from ajax doesn't work
  • MVC: Use string variables of a view as parameter to a javascript function call
  • How to simplify repeated build job syntax?
  • Use Blob field as query parameter in SQLite
  • Web Api 2: [Required] for value types?
  • “@” symbol in stored procedure?
  • Eclipse doesn't generate google cloud endpoint client library
  • MySQL very slow query with custom function in spite of LIMIT
  • Type specific constructor for generic class
  • Using target on div without a href
  • Is it possible to extract table infomation using Apache Tika?
  • Using docker environment -e variable in supervisor
  • Nginx rewrite equivalent to Apache RewriteRule that converts URL params into QueryString key/value p
  • JSF2.0 + Primefaces 3.0.1 + jquery 1.6.4 + p:commandLink + IE8 throws Unexpected call to method or p
  • Doctrine2 bulk import try to work with another entity
  • Passing “get” parameters doesn't work, parameter not visible in the link
  • Redux Form - Not able to type anything in input
  • Declaring variable dynamically in VB.net
  • How can I sort a a table with VBA with given text condition?
  • All Classes Conforming to Protocol Inherit Default Implementation
  • Deselecting radio buttons while keeping the View Model in synch
  • Sony Xperia Z Tablet not found by adb
  • How to recover from a Spring Social ExpiredAuthorizationException
  • Submit form in a displaytag pagination
  • Fill an image in a square container while keeping aspect ratio
  • JSON with duplicate key names losing information when parsed
  • Convert array of 8 bytes to signed long in C++
  • How can I estimate amount of memory left with calling System.gc()?
  • Jquery - Jquery Wysiwyg return html as a string
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Hits per day in Google Big Query
  • Understanding cpu registers
  • python draw pie shapes with colour filled
  • Recursive/Hierarchical Query Using Postgres
  • Running Map reduces the dimensions of the matrices
  • Reading document lines to the user (python)
  • How to Embed XSL into XML