You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Bruce Link <Br...@bcit.ca> on 2006/02/26 00:34:05 UTC

Interaction between Struts and Tiles - redirect doesn't?





I am trying to put together an example j2ee web site using struts/tiles as
the front end, using struts 1.2.8.  I have been trying to guess and
experiment to find out how to merge the two, since most examples just use
jsp pages for the view layer, and I am trying to use tiles throughout.
What more or less works is to define each tiles page, and use them as the
target of forward actions.  Where the examples give a jsp input, I use a
forward action that goes to the tile.  However, I then wind up with a
forward to the confirmation page, where I would like a redirect (to avoid
reposting problems).  I tried to add redirect="true" as below, but it still
forwards (with the action defined below, the final confirmation page
displays /host/context/newUser.do in the browser window).  I attempted
changing path from page.newUserConfirmation to /newUserConfirmation and
defining an action with path /newUserConfirmation to forward to
page.newUserConfirmation, but I get the context root added to  the url.

Any ideas on how to get redirected to the confirmation page?

    <action
      attribute="newUserForm"
      input="/newUserForm.do"
      name="newUserForm"
      path="/newUser"
      scope="request"
      type="ca.bcit.infosys.web.action.NewUserAction">
      <forward name="showNewUserConfirmation" redirect="true" path=
"page.newUserConfirmation" />
    </action>
    <action path="/newUserForm"  scope="request" validate="false" forward=
"page.newUserForm" />

Re: Interaction between Struts and Tiles - redirect doesn't?

Posted by Mark Lowe <me...@gmail.com>.
You should be able to redirect to an action that then forwards to the
tiles definition..

Something like

<action path="/foo" type="YourAction">
   <forward name="success" value="/bar.do" redirect="true" />
</action>

<action path="/bar" type="YourAction">
  <forward name="success" value="your.tile.def" />
</action>

Its not perfect, but then what is?

Mark

On 2/27/06, Bruce Link <Br...@bcit.ca> wrote:
>
>
> I can do those things, but forwarding is not a problem. What I am trying to
> do is redirect. Even though I give 'redirect="true"' (as shown in original
> post) struts does a forward. I can tell by the URL shown in the browser, as
> well as reloading which posts to newUser.do whereas I want it to go to the
> confirmation page (what I want is the typical pattern to avoid reloading the
> page doing a duplicate post, in this case creating a new user twice)
>
>  Bruce
>  Laurie Harper <la...@holoweb.net>
>
>
>
>
>
>
>
> Laurie Harper <la...@holoweb.net>
>  Sent by: news <ne...@sea.gmane.org>
>
> Feb 26, 2006 07:59 PM
> Please respond to
>  "Struts Users Mailing List" <us...@struts.apache.org>
>
>
> To
>  user@struts.apache.org
>
>
> cc
>
>
>
> Subject
>  Re: Interaction between Struts and Tiles - redirect doesn't?
>
>
>  That seems kinda redundant to me ;-) Just use the ForwardAction that
>  comes with Struts:
>
>    <action path="..."
> type="org.apache.struts.actions.ForwardAction"
>            parameter="page.newUserForm"/>
>
>  I think you can also do something like this,
>
>    <action path="..." forward="page.newUserForm"/>
>
>  Not sure about that, though.
>
>  L.
>
>  Mark Lowe wrote:
>  > For some reason a simple forwarding action needs to go through an action
> class.
>  >
>  > Something like
>  >
>  > public class BlankAction extends Action {
>  > public ActionForward execute(..) throws Exception {
>  >     return mapping.findForward("success");
>  > }
>  > }
>  >
>  > <action path="/newUserForm" type="foo.struts.BlankAction">
>  >    <forward name="success" value="page.newUserForm" />
>  > </action>
>  >
>  >
>  > Should work just fine.
>  >
>  > Mark
>  >
>  >
>  > On 2/26/06, Bruce Link <Br...@bcit.ca> wrote:
>  >>
>  >>
>  >>
>  >>
>  >> I am trying to put together an example j2ee web site using struts/tiles
> as
>  >> the front end, using struts 1.2.8.  I have been trying to guess and
>  >> experiment to find out how to merge the two, since most examples just
> use
>  >> jsp pages for the view layer, and I am trying to use tiles throughout.
>  >> What more or less works is to define each tiles page, and use them as
> the
>  >> target of forward actions.  Where the examples give a jsp input, I use a
>  >> forward action that goes to the tile.  However, I then wind up with a
>  >> forward to the confirmation page, where I would like a redirect (to
> avoid
>  >> reposting problems).  I tried to add redirect="true" as below, but it
> still
>  >> forwards (with the action defined below, the final confirmation page
>  >> displays /host/context/newUser.do in the browser window).  I attempted
>  >> changing path from page.newUserConfirmation to /newUserConfirmation and
>  >> defining an action with path /newUserConfirmation to forward to
>  >> page.newUserConfirmation, but I get the context root added to  the url.
>  >>
>  >> Any ideas on how to get redirected to the confirmation page?
>  >>
>  >>     <action
>  >>       attribute="newUserForm"
>  >>       input="/newUserForm.do"
>  >>       name="newUserForm"
>  >>       path="/newUser"
>  >>       scope="request"
>  >>       type="ca.bcit.infosys.web.action.NewUserAction">
>  >>       <forward name="showNewUserConfirmation" redirect="true" path=
>  >> "page.newUserConfirmation" />
>  >>     </action>
>  >>     <action path="/newUserForm"  scope="request" validate="false"
> forward=
>  >> "page.newUserForm" />
>
>
> ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>  For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>

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


Re: Interaction between Struts and Tiles - redirect doesn't?

Posted by Bruce Link <Br...@bcit.ca>.



I can do those things, but forwarding is not a problem.  What I am trying
to do is redirect.  Even though I give 'redirect="true"' (as shown in
original post) struts does a forward. I can tell by the URL shown in the
browser, as well as reloading which posts to newUser.do whereas I want it
to go to the confirmation page (what I want is the typical pattern to avoid
reloading the page doing a duplicate post, in this case creating a new user
twice)

Bruce


                                                                           
             Laurie Harper                                                 
             <laurie@holoweb.n                                             
             et>                                                        To 
             Sent by: news             user@struts.apache.org              
             <news@sea.gmane.o                                          cc 
             rg>                                                           
                                                                   Subject 
                                       Re: Interaction between Struts and  
             Feb 26, 2006              Tiles - redirect doesn't?           
             07:59 PM                                                      
                                                                           
                                                                           
             Please respond to                                             
               "Struts Users                                               
               Mailing List"                                               
             <user@struts.apac                                             
                  he.org>                                                  
                                                                           
                                                                           




That seems kinda redundant to me ;-) Just use the ForwardAction that
comes with Struts:

   <action path="..." type="org.apache.struts.actions.ForwardAction"
           parameter="page.newUserForm"/>

I think you can also do something like this,

   <action path="..." forward="page.newUserForm"/>

Not sure about that, though.

L.

Mark Lowe wrote:
> For some reason a simple forwarding action needs to go through an action
class.
>
> Something like
>
> public class BlankAction extends Action {
> public ActionForward execute(..) throws Exception {
>     return mapping.findForward("success");
> }
> }
>
> <action path="/newUserForm" type="foo.struts.BlankAction">
>    <forward name="success" value="page.newUserForm" />
> </action>
>
>
> Should work just fine.
>
> Mark
>
>
> On 2/26/06, Bruce Link <Br...@bcit.ca> wrote:
>>
>>
>>
>>
>> I am trying to put together an example j2ee web site using struts/tiles
as
>> the front end, using struts 1.2.8.  I have been trying to guess and
>> experiment to find out how to merge the two, since most examples just
use
>> jsp pages for the view layer, and I am trying to use tiles throughout.
>> What more or less works is to define each tiles page, and use them as
the
>> target of forward actions.  Where the examples give a jsp input, I use a
>> forward action that goes to the tile.  However, I then wind up with a
>> forward to the confirmation page, where I would like a redirect (to
avoid
>> reposting problems).  I tried to add redirect="true" as below, but it
still
>> forwards (with the action defined below, the final confirmation page
>> displays /host/context/newUser.do in the browser window).  I attempted
>> changing path from page.newUserConfirmation to /newUserConfirmation and
>> defining an action with path /newUserConfirmation to forward to
>> page.newUserConfirmation, but I get the context root added to  the url.
>>
>> Any ideas on how to get redirected to the confirmation page?
>>
>>     <action
>>       attribute="newUserForm"
>>       input="/newUserForm.do"
>>       name="newUserForm"
>>       path="/newUser"
>>       scope="request"
>>       type="ca.bcit.infosys.web.action.NewUserAction">
>>       <forward name="showNewUserConfirmation" redirect="true" path=
>> "page.newUserConfirmation" />
>>     </action>
>>     <action path="/newUserForm"  scope="request" validate="false"
forward=
>> "page.newUserForm" />


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


Re: Interaction between Struts and Tiles - redirect doesn't?

Posted by Laurie Harper <la...@holoweb.net>.
That seems kinda redundant to me ;-) Just use the ForwardAction that 
comes with Struts:

   <action path="..." type="org.apache.struts.actions.ForwardAction"
           parameter="page.newUserForm"/>

I think you can also do something like this,

   <action path="..." forward="page.newUserForm"/>

Not sure about that, though.

L.

Mark Lowe wrote:
> For some reason a simple forwarding action needs to go through an action class.
> 
> Something like
> 
> public class BlankAction extends Action {
> public ActionForward execute(..) throws Exception {
>     return mapping.findForward("success");
> }
> }
> 
> <action path="/newUserForm" type="foo.struts.BlankAction">
>    <forward name="success" value="page.newUserForm" />
> </action>
> 
> 
> Should work just fine.
> 
> Mark
> 
> 
> On 2/26/06, Bruce Link <Br...@bcit.ca> wrote:
>>
>>
>>
>>
>> I am trying to put together an example j2ee web site using struts/tiles as
>> the front end, using struts 1.2.8.  I have been trying to guess and
>> experiment to find out how to merge the two, since most examples just use
>> jsp pages for the view layer, and I am trying to use tiles throughout.
>> What more or less works is to define each tiles page, and use them as the
>> target of forward actions.  Where the examples give a jsp input, I use a
>> forward action that goes to the tile.  However, I then wind up with a
>> forward to the confirmation page, where I would like a redirect (to avoid
>> reposting problems).  I tried to add redirect="true" as below, but it still
>> forwards (with the action defined below, the final confirmation page
>> displays /host/context/newUser.do in the browser window).  I attempted
>> changing path from page.newUserConfirmation to /newUserConfirmation and
>> defining an action with path /newUserConfirmation to forward to
>> page.newUserConfirmation, but I get the context root added to  the url.
>>
>> Any ideas on how to get redirected to the confirmation page?
>>
>>     <action
>>       attribute="newUserForm"
>>       input="/newUserForm.do"
>>       name="newUserForm"
>>       path="/newUser"
>>       scope="request"
>>       type="ca.bcit.infosys.web.action.NewUserAction">
>>       <forward name="showNewUserConfirmation" redirect="true" path=
>> "page.newUserConfirmation" />
>>     </action>
>>     <action path="/newUserForm"  scope="request" validate="false" forward=
>> "page.newUserForm" />


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


Re: Interaction between Struts and Tiles - redirect doesn't?

Posted by Mark Lowe <me...@gmail.com>.
For some reason a simple forwarding action needs to go through an action class.

Something like

public class BlankAction extends Action {
public ActionForward execute(..) throws Exception {
    return mapping.findForward("success");
}
}

<action path="/newUserForm" type="foo.struts.BlankAction">
   <forward name="success" value="page.newUserForm" />
</action>


Should work just fine.

Mark


On 2/26/06, Bruce Link <Br...@bcit.ca> wrote:
>
>
>
>
>
> I am trying to put together an example j2ee web site using struts/tiles as
> the front end, using struts 1.2.8.  I have been trying to guess and
> experiment to find out how to merge the two, since most examples just use
> jsp pages for the view layer, and I am trying to use tiles throughout.
> What more or less works is to define each tiles page, and use them as the
> target of forward actions.  Where the examples give a jsp input, I use a
> forward action that goes to the tile.  However, I then wind up with a
> forward to the confirmation page, where I would like a redirect (to avoid
> reposting problems).  I tried to add redirect="true" as below, but it still
> forwards (with the action defined below, the final confirmation page
> displays /host/context/newUser.do in the browser window).  I attempted
> changing path from page.newUserConfirmation to /newUserConfirmation and
> defining an action with path /newUserConfirmation to forward to
> page.newUserConfirmation, but I get the context root added to  the url.
>
> Any ideas on how to get redirected to the confirmation page?
>
>     <action
>       attribute="newUserForm"
>       input="/newUserForm.do"
>       name="newUserForm"
>       path="/newUser"
>       scope="request"
>       type="ca.bcit.infosys.web.action.NewUserAction">
>       <forward name="showNewUserConfirmation" redirect="true" path=
> "page.newUserConfirmation" />
>     </action>
>     <action path="/newUserForm"  scope="request" validate="false" forward=
> "page.newUserForm" />

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