Can we call an Action from another Action in struts???

Discussion in 'Java' started by vyshu, Apr 27, 2007.

  1. vyshu

    vyshu Guest

    hi,
    Let me explain my situation.
    I have a form for updating the customer details.when ever the user
    say submit,it calls the action and performs the updation.Now comes my
    problem,I want to redirect back to the same update page with the newly
    updated values.I think you got what i meant.
    Let me be specific,Can i call an action from another action?.

    somthing like
    new ActionForward("something");
    this should call another form bean and Action.

    If it is possible please do let me know.
    waiting for your suggestions.
    thanks,
    vysh.
    vyshu, Apr 27, 2007
    #1
    1. Advertising

  2. vyshu wrote:

    > Let me be specific,Can i call an action from another action?.
    >
    > somthing like
    > new ActionForward("something");
    > this should call another form bean and Action.


    You can define a forward in the Struts config file that refers to an
    action, e.g.

    <forward name="something" path="/Something.do"/>

    ...

    <action path="/Something" ... />

    Then your action can do this:

    return mapping.findForward("something");

    You need to establish a strategy for organising actions around pages,
    otherwise you will get yourself in a knot. For example, do you have an
    action that populates the request with the required data for the view
    (i.e. the JSP), forward to that view, then have another action that
    processes the submit? Or do you combine the two actions into one, using
    parameter derived from the form button to choose your course through a
    single action.

    Have a look at this, particularly the sections starting at "Two actions,
    one form":

    http://www.theserverside.com/tt/articles/article.tss?l=StrutsActionMapping

    Also, try some searches on "action chaining", e.g.

    http://husted.com/poe/17 Oct 2005.html
    http://www.javaworld.com/javaworld/jw-09-2004/jw-0913-struts.html?page=4

    --
    Regards,

    Richard
    Richard Senior, Apr 27, 2007
    #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:
    751
    Sudsy
    Aug 3, 2003
  2. rjweytens
    Replies:
    6
    Views:
    16,083
    rjweytens
    Jun 25, 2004
  3. Replies:
    0
    Views:
    1,238
  4. runescience

    Struts mapping action to action???

    runescience, Feb 6, 2006, in forum: Java
    Replies:
    3
    Views:
    1,820
    runescience
    Feb 7, 2006
  5. John
    Replies:
    0
    Views:
    860
Loading...

Share This Page