wood burning stoves*
The moose likes Struts and the fly likes The old mutliple pages submit to one action problem... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "The old mutliple pages submit to one action problem..." Watch "The old mutliple pages submit to one action problem..." New topic
Author

The old mutliple pages submit to one action problem...

Paul Duer
Ranch Hand

Joined: Oct 10, 2002
Posts: 98
Hi guys,
This is one of those common questions that I just forget the answer to.
If you use the INPUT tag in an action mapping, you give struts a JSP page or another action to return control to when form validation errors are found.
Now what do you do when you have a couple different JSP pages, or forms I geuss, that can submit to the same action mapping?
Is this just one of those things you shouldn't do? Like we all should be using tiles or something so that our page links are generic?
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4462
    
    6

Are these unrelated pages or are they related, as in a wizard? In Struts 1.1 an Exception will be thrown if you try to change the input of a mapping once it has been configured. Prior to 1.1 you could change it programmatically via setInput().
I don't know if there's another approach but my workaround is to bypass the call to validate() at the framework level by setting validate=false in struts config, then invoke the form's validate() in the Action's execute() method. If I get errors back, save them and since I know which page I'm currently on, just forward to that page.


Junilu - [How to Ask Questions] [How to Answer Questions]
Paul Duer
Ranch Hand

Joined: Oct 10, 2002
Posts: 98
Junliu,
You kinda hit the nail on the head. In my example, or at least what I am thinking about, is you have two totaly unrelated business pages. Meaning that while the relate to the same data interaction, they are entered for different reasons.
A good example is a "pipeline" page, I have one for open and one for closed. They access the same data, but they present a different dataset with different columns and needs.
So I usally use a single action to recieve requests, usally basic stuff that is done on either page. So this is where you get into the issue.
I guess it seems like the rule is, if you have more than one page using the same action, you can't validate much at the form level, but in the action you can do whatever you want.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The old mutliple pages submit to one action problem...