Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Struts validation problem

Status
Not open for further replies.

mdmohideen

Programmer
Mar 5, 2002
5
US
Hi All,
I have a question on Struts.
Here is the scenario, I am clicking a action menu item. It calls an struts action x and forwards to a jsp page.
Once I fill the form(DynaValidatorForm), then I am submitting and calling the same action x. Now the form has to be validated.
----------------------------------------------------------------
When I set the validate = true in the config for this particular action, the form loading fails becoz of validation fails. The validate is invoked since the action path is same for load and submit.
I need a solution for this problem. I want to set the validate attribute only when the form is submitted, not while loading.
Please help me in this issue.
Appreciate your effort for this reading issue.
Thanks,
Mohideen.

 
Hi,

I am not sure as I haven't tried this. But there is an alternate way. May be this could help you. Create a DummyAction when you are loding a page and validate the form when you submit the page with values.

Ex:

<action path=&quot;/Test&quot; type=&quot;com.test.action.DummyAction&quot;>
<forward name=&quot;success&quot; path=&quot;/test.jsp&quot;/>
</action>

Then

<action path=&quot;/Test&quot; type=&quot;com.test.action.OrginalAction&quot; validate=&quot;true&quot;>
<forward name=&quot;success&quot; path=&quot;/destPage.jsp&quot;/>
</action>

All your DummyAction will have a simple forward to the test page in the execute method.

Cheers,
-Venu




 
Sorry,

Please in action mapping change the Path either for DummyAction or OrginalAction, it should not be same.

Cheers,
-Venu

 
Hi Venur,
Thanks for your response. My tech manager gave me another way to implement this.
For the form load view, he suggested me to have a displayaction. On submit to different action.
something like this,
Ex:

<action path=&quot;/displayform&quot; type=&quot;com.test.action.DisplayFormAction&quot;>
<forward name=&quot;success&quot; path=&quot;/form.jsp&quot;/>
</action>

Then

<action path=&quot;/manageform&quot; type=&quot;com.test.action.ManageFormAction&quot; validate=&quot;true&quot;>
<forward name=&quot;success&quot; path=&quot;/form.jsp&quot;/>
</action>

Your response is correlating with the above one. By this way we can avoid a dummy action.

Thanks again,
Mohideen.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top