Hi,
I am creating a JSF application. I have some items (e.g. products) from database and I want to create a JSF page for editing particular items, that is:
- it should display selected item properties and enable user to edit them,
- I want to be able to view this item with some link,
- I want JSF to somehow remember that I'm editing particular item (e.g. after editing its data it should display this item page)
I have a problem with storing/passing id of item being edited. I saw that in sample JSF CarDemo application they store item (car) being viewed in session. I don't want to do this because I want user to be able to edit different elements in separate browser tabs.
I tried several approaches:
- using some (e.g.
itemId
) GET parameter in URL, but it makes it difficult to go back to item page after editing data (to-view-id
field in faces-config.xml can only contain constants), - using some backing bean managed-property and passing its value in each hyperlink and in forms (by adding hidden field)
The problem I still can't eliminate is that if after editing some item properties I try to save them and validation (e.g. f:validateLength
) fails the page is reloaded but id of item being edited is lost. I think it is quite standard task when creating web applications (e.g. user edition, store products edition) so there certainly should be some solution.
Thanks in advance.