my dog learned polymorphism
The moose likes Struts and the fly likes How to submit a form like this, using struts? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to submit a form like this, using struts?" Watch "How to submit a form like this, using struts?" New topic

How to submit a form like this, using struts?

jaman tai
Ranch Hand

Joined: Sep 26, 2005
Posts: 37
I have a form having 3 buttons. One is �Approve�, one is �Reject� and one is �Back�. If click Approve, update db directly and back. If click �Reject�, pup up a small window to ask the reject reason. (I am using javascript�s after input the reason and click �go�, close the small window, update db and the original page goes back. If click �Back�, go back directly. How can I design this page? I know a little about LookupDispatchAction. Can anybody help me? Thanks a lot!
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

Moving to the Struts forum...

A good workman is known by his tools.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
For this, I'd use DispatchAction rather than LookupDispatchAction. The main reason for using LookupDispatchAction over DispatchAction is that it allows you to avoid using JavaScript. Since you have to pop up a window, you have to use JavaScript anyway.

Here's what I'd do:

1-Code an Action extending DispatchAction with accept() reject() and back() methods.
2-Put a hidden field in your JSP named "actionCode" with a corresponding property in your ActionForm.
3-Specify parameter="actionCode" when you define the action path.
4-When any of the buttons are pressed, use JavaScript to change the value of actionCode appropriately and submit the form.
5-In the case of a reject, code a hidden field named "rejectReason" in your main JSP. When the user presses the reject button, pop up the window. When the user presses go on the popup window, use JavaScript to populate the rejectReason field, change the actionCode appropriately, submit the form, and close the popup window.

Consultant, Sima Solutions
I agree. Here's the link:
subject: How to submit a form like this, using struts?
jQuery in Action, 3rd edition