I have 2 pages: one shows list of users in datatable, say listusers.jsp, another — user's details and it's activities on some date (in datatable too), say viewuser.jsp.
The second page is backed by viewUserBean, which has properties currentUserId, currentDayId.
To come from listusers.jsp to viewuser.jsp I do the next thing
Then on viewuser.jsp I want to select a day of activity, and I do this
The backed bean is in request scope, and I believe, it should be there. But the problem is that it's currentUserId property isn't persist between requests. So if I select some plan, page will be redisplayed as I've passed currentUserId = null to it.
How to keep currentUserId property of the backed bean, which is in request scope between requests?
If your current userId is bound to hutputText in your viewUser.jsp, then it won't get back to your viewUserBean during request submit and the value will be lost. It seems that you are just displaying the UserId in viewuser.jsp and hence it is not persisting between requests. I could see a couple of approaches to this problem
You can store the userId as a session attribute and then retrieve it for the next request from your viewUserBean. This would need some additional code in your bean.
If you are using JSF 2.0 or higher, your viewuserbean is a very good candidate for @ViewScoped Bean. The bean stays as long as you are on the same page, that is on viewuser.jsp. Once you are done with viewuser.jsp and navigate to some other page of your application the bean will go out of scope.
Joined: Nov 02, 2010
Thank you for reply.
Seems, like session scope is my the only choise.
I'm using Spring for managing JSF beans, and so I can't declare my bean to be in view scope in a simple way. I have to implement such scope at first, that is not a simple task for at the moment. Anyway, thanks for this info, I didn't know about this scope type.
Maybe recreating bean property is possible with hidden input?
I've tried to play with it already, but it didn't work for me.