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 reload request level lists after validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "reload request level lists after validation" Watch "reload request level lists after validation" New topic
Author

reload request level lists after validation

Fletcher Munson
Ranch Hand

Joined: May 16, 2007
Posts: 31
I'm using Struts 2, and I have a number of fields on which I perform some basic validation. Upon submission everything goes to the MyClass-validations.xml and the fields fail/pass. When they pass everything is rosey, but when they fail I get exceptions. The root of this is that I have a list that is retrieved by another action on page load. What I need to know is - is there a way to get hang on to this request level list for reuse if validation fails? Thanks in advance.


SCJP 5, SCWCD 1.4
Fletcher Munson
Ranch Hand

Joined: May 16, 2007
Posts: 31
I've resolved this by using the validate method.



pretty simple
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

FWIW, you could just have a getter in the action that returns the list and skip putting it in the request altogether.

That has the side benefit of taking non-validation stuff out of the validate() method.
Fletcher Munson
Ranch Hand

Joined: May 16, 2007
Posts: 31
I'm entering transactions for an accounting system, and I need to retrieve the list based on the type of transaction. I use an initial action on page load to determine what the list will contain. I need to perform the same assessment during validation. If I just use a getter I didn't think the jsp would know about the type when it renders the page. Or am I wrong?

This brings me to my next question which I think should be a new topic.

Please take a look:

http://www.coderanch.com/t/428245/Struts/Using-multiple-JSPs-one-Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: reload request level lists after validation