Meaningless Drivel is fun!*
The moose likes Struts and the fly likes issue with scope of a form bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "issue with scope of a form bean" Watch "issue with scope of a form bean" New topic
Author

issue with scope of a form bean

Souvvik Basu
Ranch Hand

Joined: Apr 05, 2010
Posts: 95
I am creating an online exam application, and I am stuck with a validation issue.

I have a link on a jsp page adminHomePage.jspwhich calls an action that retrieves all Tests and all Users present in the database. The form bean being used is TestsNStudentsInfoForm. On success, the list of tests and students are being displayed on a new jsp testRegistration.jsp in drop-down fields. On this new jsp, I am using Struts validation framework to validate for empty fields. The testRegistration.jsp page uses its own form bean TestRegistrationForm to carry the workflow forward. However, the validation method is giving an error


When I convert the TestsNStudentsInfoForm bean from request to session scope, the error is rectified.

Now, my question is, why does the framework look at the bean whose use is already over, and which is not being used at all for the current workflow? Also, as long as the fields are not empty, and the code to add an ActionMessage to the ActionError object is not being executed, it is working fine. Looks like the framework is searching for the old bean before adding an action error, but not otherwise.

Here are my codes

adminHomePage.jsp


On clicking the link Allow a Student for a Test the /retrieveTestsNStudents path is followed. the struts-config.jsp for this mapping is


The data is being pulled correctly and displayed correctly on testRegistration.jsp.
testRegistartion.jsp


On clicking the submit button, the following mapping is invoked

The TestRegistrationForm bean is this


My apologies for the long post, but the issue seems to be tied to 2 actions, so I gave both the flows.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: issue with scope of a form bean
 
Similar Threads
Invoking Struts Action from javascript bypassing ActionForm
Cannot find bean: "org.apache.struts.taglib.html.BEAN" in any scope for File Handling
page keep on refreshing
Multipart request problem
exchanging values from right to left on button click