I actualy had a similar question before and the answer I came up with was to
describe that universal action in struts-config w/o input and forwards, then
define the views/jsp pages this action will be called from as global
forwards and then use the global forwards aliases as a value passed as
parameter to the action.

example:

in struts-config.xml

  <global-forwards>
    <forward name="home" path="/index.jsp"/>
    <forward name="rv" path="/registrationView.jsp"/>
  </global-forwards>

    <action
      path="/myAction"
      type="MyAction"
      name="myActionForm"
      scope="request"
    >
    </action>

public final class MyActionForm extends ActionForm  {

  // view
  private String view;

  public void setView(String val){
    this.view = val;
  }

  public String getView(){
    return view;
  }

}

public final class MyAction extends Action{
    public ActionForward perform(ActionMapping mapping,
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
                                 throws IOException, ServletException
    {

      String view = ((MyActionForm)form).getView();
       ...
      return mapping.findForward(view);
  }
}

so in your index.jsp
<a href="/myAction.action?view=home>process</a>

in registrationView.jsp
<a href="/myAction.action?view=rv>process</a>

so you defined one action and the user still will not see the real view
names.

If anybody has a better solution besides extending ActionServlet , let me
know beacuse I'd like to make it more efficient.

Cheers,
Ivan

----- Original Message -----
From: "harish krishnaswamy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 26, 2003 8:29 PM
Subject: Action input


> Is there a way of providing the action input in a
> dynamic fashion? In other words, if I had the same
> action being submitted from multiple pages/forms, how
> would I go back to the page/form I came from?
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - forms, calculators, tips, more
> http://taxes.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to