views:

382

answers:

2

Hi,

I am using a JSF 2.0 to create a web app (purely jee6, without spring/seam etc.). I would like to have a single xhtml page but pass the proper backing bean / entity into it. For example, I would like to be able to edit a user other than the logged in user, I have a user edit page which displays the information of the logged in user (being tracked by my session), I would like to instead pass in a user selected from a list and edit that user's information, without switching the user that is stored in the session or creating a separate xhtml page (violating DRY).

The "best" way I can see to achieve this would be to reuse the exact same xhtml page that I am using to display the logged-in-user's edit page, but simply pass in a different entity in some way. Perhaps calling the setter in the backing bean before redirecting to the page (if this is even possible) or some other solution that does not violate DRY. Perhaps I have designed this all wrong, is there a way to pass in entities to JSF pages?

thanks.

+2  A: 
  1. use <f:setPropertyActionListener /> to set the desired user to a managed bean
  2. use the same xhtml page to display what has been just set in the bean.
Bozho
Thanks for the help, is there a technique i could use to determine which entity to use based on which link they clicked? As in, if they click on link A pass Entity A into xhtml page 1, of they click on link B pass Entity B into xhtml page 1? The goal would be to have a consistant table but the info in the table will be different depending on the page you wish to view...
kgrad
this depends entirely on the `value=".."` of the dataTable. You will pass the current item (`var`) to `<f:setPropertyA...>`
Bozho
A: 

see my complete example given as answer to a question

example

nash