You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Rick Reumann <ri...@gmail.com> on 2005/08/26 20:49:06 UTC

Dealing with links/buttons to fire off an action? confusion on how to set this up

I was wondering how to d something that I would think would be a common 
situation, yet I'm not finding any examples at the moment...

scenario:... list of employees. You want to be able to click on one of the 
employees and go to an "editEmployee" backing bean method that would 
retrieve the employee based on the id of the employee in the list.

I'm used to doing this with a simple link John Doe <a href="/myApp 
/setUpForEdit?employeeID=4355">Edit</a>

With JSF I'm not so sure about how to do this. My JSF book mentions briefly 
about passing in f:param in commandLink but doesn't show how to retrieve 
this param.

As a side note I find this very interesting, I was testing by using a 
DataTable and providing a commandLink next to each employee for each row...

<h:commandLink value="Edit" action="#{employee.editAction}">
<f:param name="empID" value="#{emp.id <http://emp.id>}"/>
</h:commandLink>

One of the odd/interesting things is that when I cycle through and print out 
the Request parameters I noticed that I'm getting a single parameter 
(assuming a map) that actually has the Employee info that I'm concerned with 
(2nd one):

8/26/05 02:28:55 PM DEBUG net.reumann.Employee editAction - param = 
net.reumann.Employee@91e321
08/26/05 02:28:55 PM DEBUG net.reumann.Employee editAction - param = id: 3, 
name: Rachel, age: 26
08/26/05 02:28:55 PM DEBUG net.reumann.Employee editAction - param = 
/employees.jsp

That second enry *does* correspond to the button I clicked but not sure how 
I'm supposed to get a handle to the id (actually I'm not even sure how the 
heck that got into the request based on the commandLink I set up)?

Also the f:param "empID" is *not* seen as a request parameter when I loop 
over them.

What is the typical procedure for providing a link or button to click on 
that isn't part of a form but should fire off an action method that will 
look up something based on parameter(s) ?