File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Redirecting to the JSP when validation error occurs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Redirecting to the JSP when validation error occurs" Watch "Redirecting to the JSP when validation error occurs" New topic
Author

Redirecting to the JSP when validation error occurs

Srilakshmi Vara
Ranch Hand

Joined: Jul 21, 2004
Posts: 169
Hello All,

Thanks for your suggestions before.

Have another question!

I am populated a page using some database values, if user enters some values upon that and submits the form i am redirecting to .do(which populates with DB values) but i am loosing user entered values, if i redirect to the jsp i am getting null pointer exception on populated field values.

What to do in this scenario?

Thanks in advance,
Srilakshmi
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
create a 3rd action mapping that is mapped to the same form-bean definition and used this new mapping (uri) as your 'input' attribute for the action where you set validation to true. in essense, you'll have 3 mappings (a bit ugly, yes):

1. /myaction/entry.do (name="MyForm") //where DB values are loaded initially

2. /myaction/submit.do (name="MyForm" validate="true" input="/myaction/failed.do") //where action is submited to

3. /myaction/failed.do (name="MyForm") //temporary uri to hold form values, needs to map this to a different action class that forwards to the same jsp/tile as #1 mapping.

this is a little easier if you have all 3 inside a DispatchAction. the only thing you'll have to do is create a 'failed' method in the DispatchAction and specify the param attribute's value to 'failed' for the input (input="/myaction/submit.do?action=failed").
[ May 16, 2005: Message edited by: alan do ]

-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Redirecting to the JSP when validation error occurs