Mateusz Dymczyk
Mateusz Dymczyk

Reputation: 15141

Get the <f:param> value in a jsf page?

I'm trying to pass a <f:param name="id" value="{someValue.id}" /> and retrieve it in the next page (so I can put it in an output link). This is what I tried:

<h:outputLink value="#{linkController.clientEdit}?id={id}">#{linkController.clientEdit}?id={id}</h:outputLink>

The problem is, the part that is between the tag prints what I want, i.e.: /my/path?id=1, but the output link's value is /my/path?id={id}. Is it possible to put that id value in the outputLink's value attribute?

@Edit: the whole application is a bit weird: we have a dataTable with some records, the last column hold an image which if you click sets the current row in a bean (which is keppAlive), sets the id param and shows a contextMenu (RichFaces) which has to menuItems: edit and delete. When I hit edit I want to be redirected to the edit page with the id param. The problem is the menuItem has only an action attribute which takes a String where to go, but when it goes there it doesn't change the URL in the browser. That's why I wanted to put the outputLink in the menuItem and drop the action attribute...

Upvotes: 1

Views: 5388

Answers (1)

BalusC
BalusC

Reputation: 1108852

You forgot the # EL prefix.

<f:param name="id" value="#{someValue.id}" />

Then, to access it in subsequent request, use #{param.name}. So:

#{linkController.clientEdit}?id=#{param.id}

The #{param} refers to a Map<String, String> with all request parameter name-value pairs.

Upvotes: 2

Related Questions