aspose file tools*
The moose likes Struts and the fly likes Can I have two Action for one Form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Can I have two Action for one Form " Watch "Can I have two Action for one Form " New topic
Author

Can I have two Action for one Form

Jose Pereira
Greenhorn

Joined: Dec 10, 2002
Posts: 12
The problem is I have a page that needs to call an Action when a "onchange" event occurs in a combo box ... that's s� a can make dependent combos in my page ... so I send the Form Bean with the value in my top combo ... OK ...

Now I need to call the Action from the submit button Action :roll:

do I send a value in the request so I can defer in my Action Class ??? how do I do that ???
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
You can chain actions by using a <forward/> for the first action that points to another action. I.e. something like this:

(please forgive me if I got the ".do"'s wrong -- I never remember where to include the suffix and where to omit it...)


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Larry Johnson
Greenhorn

Joined: Jan 13, 2005
Posts: 4
you could change the action via javascript in the onchange of the box and then submit it
document.forms[0].action = 'action.do'
forms[0].submit()

something like that...
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
I thought you couldn't have two actions on a form.
But you could make a form attribute called "myAction"
inside the html tags declare a hidden attribute "myAction"
and then on the the various actions that you would submit the form use javascript to change the value of my aciont then do the submit.

Inside of your one action you can reference this hidden variable and decide what to do based on that (and what forward to return).


hope that helps.

-Tad
 
 
subject: Can I have two Action for one Form