permaculture playing cards*
The moose likes Struts and the fly likes Do we always need form element to invoke action class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Do we always need form element to invoke action class?" Watch "Do we always need form element to invoke action class?" New topic
Author

Do we always need form element to invoke action class?

shah rah
Ranch Hand

Joined: Jan 04, 2007
Posts: 124
Do we always need form element to invoke action class?

For Eg.

I have a ADD screen . On pressing submit. I generate a ConfirmScreen with data enetered entered by the user in the ADD screen.

The ConfirmScreen has a OK and Cacel button. Only if the user presses ok the data has to be submitted to the database.

In my second screen I don't have any form element. Lots of Bean:write tag and a html submit and reset button. how do I call the Action class in this case?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you use an action in an <html:form> tag, it must have an ActionForm associated with it. There is no getting around this rule.

In your specific situation, I see two differnt ways you could go:
  • In your confirmation screen, embed all the data in <html:hidden> fields that correspond to the data being displayed with <bean:write> tags. Then just make the "OK" button a submit button, and the form will be submitted with the data
  • Make the confirm screen just a pop-up screen with no form in it at all. If the user presses cancel, just close the window. If she presses "OK", use JavaScript to submit the form in the parent window (opener.document.forms[0].submit()).


  • Merrill
    Consultant, Sima Solutions
    shah rah
    Ranch Hand

    Joined: Jan 04, 2007
    Posts: 124
    thnx. I am planning to take the second way.
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: Do we always need form element to invoke action class?
     
    Similar Threads
    servlet doubt
    HELP! JSP doesn't SAVE VALUES to BEAN
    Multi List Box Problem in Struts 1.1
    Struts Issue - Repopulating a Form Bean
    Finding Session Object?