You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Laurent PETIT <LP...@sqli.com> on 2003/07/28 11:36:43 UTC

RE: Design Question - same action, many jsps/views

 Hello,

one way to solve it is not to duplicate code in different Action classes,
but have many ActionMapping entries in your struts-config.xml file.

This way you keep the navigational part of your application away from Action
classes, but still avoid code duplication in Actions.

HTH,

-- 
Laurent

-----Original Message-----
From: Brian McSweeney
To: struts-user@jakarta.apache.org
Sent: 28-7-03 11:38
Subject: Design Question - same action, many jsps/views

Hi all,
 
I've come across a situation which I'm not sure how to handle with
struts.
I have an action which, depending on from which page it's called, 
should forward to different jsps pages.
 
Currently, for each resultant jsp, I create a new action with the exact
same 
logic code inside which forwards to the right jsp.
 
I'm just not sure if this is the right way to do it, because it's
replication of code.
An alternative might be to switch on the input path of the request and
forward to 
The right jsp, but I'm not sure if this is right either. This has to
have come up 
before, so I'm looking for a best practice solution.
 
What do you guys reckon?
 
Thanks,
Brian

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Design Question - same action, many jsps/views

Posted by Brian McSweeney <br...@aurium.net>.
Hi Laurent,
Thanks for the help. I'm not too sure what you mean though.

Do you mean, to just give a different path in the config file 
but map it to the same type? For example:

    <action
      path="/myCustomAction"
      type="com.mycompany.web.struts.action.MyCustomAction"
      name="myCustomForm"
      scope="request"
      unknown="false"
      validate="false"
    >
      <forward
        name="success"
        path="/page1.jsp"
        redirect="false"
      />


    <action
      path="/mySecondCustomAction"
      type="com.mycompany.web.struts.action.MyCustomAction"
      name="myCustomForm"
      scope="request"
      unknown="false"
      validate="false"
    >
      <forward
        name="success"
        path="/page2.jsp"
        redirect="false"
      />

    <action
      path="/myThirdCustomAction"
      type="com.mycompany.web.struts.action.MyCustomAction"
      name="myCustomForm"
      scope="request"
      unknown="false"
      validate="false"
    >
      <forward
        name="success"
        path="/page3.jsp"
        redirect="false"
      />


Is this what you mean?
Thanks,
Brian

-----Original Message-----
From: Laurent PETIT [mailto:LPETIT@sqli.com] 
Sent: 28 July 2003 10:37
To: 'Brian McSweeney '; 'struts-user@jakarta.apache.org '
Subject: RE: Design Question - same action, many jsps/views

 Hello,

one way to solve it is not to duplicate code in different Action
classes,
but have many ActionMapping entries in your struts-config.xml file.

This way you keep the navigational part of your application away from
Action
classes, but still avoid code duplication in Actions.

HTH,

-- 
Laurent

-----Original Message-----
From: Brian McSweeney
To: struts-user@jakarta.apache.org
Sent: 28-7-03 11:38
Subject: Design Question - same action, many jsps/views

Hi all,
 
I've come across a situation which I'm not sure how to handle with
struts.
I have an action which, depending on from which page it's called, 
should forward to different jsps pages.
 
Currently, for each resultant jsp, I create a new action with the exact
same 
logic code inside which forwards to the right jsp.
 
I'm just not sure if this is the right way to do it, because it's
replication of code.
An alternative might be to switch on the input path of the request and
forward to 
The right jsp, but I'm not sure if this is right either. This has to
have come up 
before, so I'm looking for a best practice solution.
 
What do you guys reckon?
 
Thanks,
Brian


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org