hi all , here is my situation ! i have 2 pages Test1.jsp and Test2.jsp
Test1 has a submit button and it populates an arrayList in managed bean and takes me to Test2.jsp. Test2.jsp has one inputText component , selectoneMenu component and a submit button. The inputText component is a required field, so i have the validator for that. My issue is, if i keep the managedbean in session scope everything works fine but if i keep it in request scope and clicks on submit button on Test2.jsp without entering any values in inputText it throws NoSuchElement exception , instaed of showing validation error.
here is my code for reference. Appretiate if someone could expalin why its not working
this code is getting invoked when i click the submit button of Test1.jsp
test2.jsp for populating selectonemenu
"MyClass" is a managed bean. if i keep this is session scope, it works fine but if i keep in request scope.. it throws java.util.NosuchElement exception when i click submit button on Test2. hope i am not making much confusions..
Well that is because you have two requests. One for test1 and another for test2. After you get test1 all variables for that request are disposed. So when the request for test2 comes in your bean no longer exists (it existed in the previous request, the one for test1).
Joined: Aug 27, 2002
Thanks for the reply, Gerardo ...What is the solution for this ? is it mandatory to store managed bean in session scope ? but i dont wanna do that !
Thanks again, Rajeev
Joined: Feb 08, 2005
Well just populate the list on test2.jsp and don't use test1.jsp. Ditch it. From what I understand you only populate the selectList on test1, you don't actually use it. Do you? So you can move that initialization to test2.jsp