Reputation: 4609
I have a table in my jsf application with some data from the database. I have made the id values a link, and my goal is to pass the data from the selected row to another facelet. How can I do this? The href I have is:
<td><a href="editOrDeletePage.xhtml?productid=#{product.id}">#{product.id}</a></td>
So the goal is that when the user clicks the link, the editOrDeletePage is displayed, and I want the editOrDeletePage to "ingest" the product id, so that it knows what data to display? How can I do this?
Upvotes: 1
Views: 535
Reputation: 415
If you definetely want to use static links, you may, of course, just read a request parameter from a target page using some kind of event listener
<f:event listener="#{bean.preRender}" type="preRenderView" />
And read the parameter from request:
FacesContext facesContext = FacesContext.getCurrentInstance();
String productId = (String) facesContext.getExternalContext().
getRequestParameterMap().get("productid");
But it's not really a JSF way to handle navigation, I belive. You may want to use commandLink or some other way of handling user actions. Or maybe, even better, think of using data table, where a user can choose a row, and you can process selection.
Upvotes: 2