How can I avoid validating a form before data is entered?
The simplest way is to have two actions. The first one has the job of setting the form data, i.e. a blank registration screen. The second action in our writes the registration data to the database. The framework would take care of invoking the validation and returning the user to the correct screen if validation was not complete.
The EditRegistration action in the Struts MailReader application illustrates this:
<action path="/editRegistration" type="org.apache.struts.webapp.example.EditRegistrationAction" attribute="registrationForm" scope="request" validate="false"> <forward name="success path="/registration.jsp"/> </action>
When the /editRegistration action is invoked, a registrationForm is created and added to the request, but its validate method is not called. The default value of the validate attribute is true , so if you do not want an action to trigger form validation, you need to remember to add this attribute and set it to false .
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.