Struts and form action

Discussion in 'Java' started by Bednarski Adam, Aug 11, 2005.

  1. Hello
    I'm beginner in Strus.
    I've got question about "form" tag in Struts.

    For example i've got page "Action_1.jsp" wich is called with "Action_1.do":

    <html:form action="Action_2.do">
    ..
    ..
    ..
    <html:submit>Submit</html:submit>
    </html:form>

    this page gets data from "Action_1_Form" but also from "Action_2_Form" !

    So my question is: why Struts is geting data from "Action_2_Form" ?
    In my opinion Struts should get data from "Action_2_Form" after clicking
    "Submit" button.

    Here is my "struts-config.xml":

    <action
    path="/Action_1"
    type="net.Action_1_form"
    scope="request"
    <forward name="succes" path="/Action_1.jsp">
    </action>
    <action
    path="/Action_2"
    type="net.Action_2_form"
    scope="request"
    <forward name="succes" path="/Action_2.jsp">
    </action>
     
    Bednarski Adam, Aug 11, 2005
    #1
    1. Advertising

  2. Bednarski Adam wrote:
    > Hello
    > I'm beginner in Strus.
    > I've got question about "form" tag in Struts.
    >
    > For example i've got page "Action_1.jsp" wich is called with "Action_1.do":
    >
    > <html:form action="Action_2.do">
    > .
    > .
    > .
    > <html:submit>Submit</html:submit>
    > </html:form>
    >
    > this page gets data from "Action_1_Form" but also from "Action_2_Form" !
    >
    > So my question is: why Struts is geting data from "Action_2_Form" ?
    > In my opinion Struts should get data from "Action_2_Form" after clicking
    > "Submit" button.
    >
    > Here is my "struts-config.xml":
    >
    > <action
    > path="/Action_1"
    > type="net.Action_1_form"
    > scope="request"
    > <forward name="succes" path="/Action_1.jsp">
    > </action>
    > <action
    > path="/Action_2"
    > type="net.Action_2_form"
    > scope="request"
    > <forward name="succes" path="/Action_2.jsp">
    > </action>
    >
    >


    If your config file really looks like this, the question doesn't make
    too much of sense, and your class naming is confusing at best.

    The "type" attribute of an action specifies the Action class whose
    execute method will be invoked when a request comes in with the "path"
    specified. So if a request comes in for Action_1.do, I'd expect it to
    invoke the execute method in the class "net.Action_1_form" - which must
    be a descendant of "Action" - not of "ActionForm".

    And the Action_1.jsp would derive no "data" at all from the
    Action_2_form class (which again I'd expect to be an Action - not an
    ActionForm) - except that when the form is submitted, the execute method
    of that class would be asked to process it.

    BK
     
    Babu Kalakrishnan, Aug 13, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe Bloggs
    Replies:
    1
    Views:
    924
    Sudsy
    Aug 3, 2003
  2. rjweytens
    Replies:
    6
    Views:
    16,253
    rjweytens
    Jun 25, 2004
  3. runescience

    Struts mapping action to action???

    runescience, Feb 6, 2006, in forum: Java
    Replies:
    3
    Views:
    1,915
    runescience
    Feb 7, 2006
  4. vyshu
    Replies:
    1
    Views:
    2,631
    Richard Senior
    Apr 27, 2007
  5. John
    Replies:
    0
    Views:
    976
Loading...

Share This Page