You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dimitris Mouchritsas <di...@eurodyn.com> on 2008/03/19 14:02:30 UTC

Implementing a back button without Javascript

Hi all,
we're using struts 1.2.4 in our project and I'm trying to implement a 
back button for a 3 step registration procedure. The problem is I'd
like to do it without using javascript. I've discovered html:cancel 
which works nicely for ...canceling. But I couldn't find anything similar
for the back button. Any ideas?
Thanks

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


Re: Implementing a back button without Javascript

Posted by Antonio Petrelli <an...@gmail.com>.
2008/3/19, Dimitris Mouchritsas <di...@eurodyn.com>:
>
> Antonio Petrelli wrote:
> > 2008/3/19, Dimitris Mouchritsas <di...@eurodyn.com>:
> >
> >> we're using struts 1.2.4 in our project and I'm trying to implement a
> >> back button for a 3 step registration procedure. The problem is I'd
> >> like to do it without using javascript. I've discovered html:cancel
> >> which works nicely for ...canceling. But I couldn't find anything
> similar
> >> for the back button. Any ideas?
> >>
> >
> >
> >
> > You need to manage it on the server side. There are many ways to do it,
> just
> > to mention a pair:
> > 1) the button points to the previous action;
> > 2) implement a history manager that manages the history of called
> actions
> > and, when called "back" (e.g. with a "history action") you go back in
> the
> > history.
> >
> > Ciao
> > Antonio
> >
> >
>
> The first case would suit me fine. But how would I do this exactly? Use
> a simple button instead of <html:button> and include it in a <a> element?
> I'm trying to do this as uniform as possible as with the other buttons
> which are <htm:submit>, <html:reset> and <html:cancel>.
> My current code looks like this:
> <a href="<%=request.getContextPath()%>/home.do">
>   <html:button styleClass="button" property="back">
>     <bean:message key="prompt.back.button" />
>   </html:button>
> </a>
> but I still need to add a back property to the form bean which is not
> really needed.



The way is simpler than you may think :-)
You can create a new *form*, different from the main one, in which there is
an <html:submit> button that triggers the action that takes you "back".

Antonio

Re: Implementing a back button without Javascript

Posted by Dimitris Mouchritsas <di...@eurodyn.com>.
Antonio Petrelli wrote:
> 2008/3/19, Dimitris Mouchritsas <di...@eurodyn.com>:
>   
>> we're using struts 1.2.4 in our project and I'm trying to implement a
>> back button for a 3 step registration procedure. The problem is I'd
>> like to do it without using javascript. I've discovered html:cancel
>> which works nicely for ...canceling. But I couldn't find anything similar
>> for the back button. Any ideas?
>>     
>
>
>
> You need to manage it on the server side. There are many ways to do it, just
> to mention a pair:
> 1) the button points to the previous action;
> 2) implement a history manager that manages the history of called actions
> and, when called "back" (e.g. with a "history action") you go back in the
> history.
>
> Ciao
> Antonio
>
>   
The first case would suit me fine. But how would I do this exactly? Use 
a simple button instead of <html:button> and include it in a <a> element?
I'm trying to do this as uniform as possible as with the other buttons 
which are <htm:submit>, <html:reset> and <html:cancel>.
My current code looks like this:        
<a href="<%=request.getContextPath()%>/home.do">
  <html:button styleClass="button" property="back">
    <bean:message key="prompt.back.button" />
  </html:button>
</a>
but I still need to add a back property to the form bean which is not 
really needed.


Re: Implementing a back button without Javascript

Posted by Antonio Petrelli <an...@gmail.com>.
2008/3/19, Dimitris Mouchritsas <di...@eurodyn.com>:
>
> we're using struts 1.2.4 in our project and I'm trying to implement a
> back button for a 3 step registration procedure. The problem is I'd
> like to do it without using javascript. I've discovered html:cancel
> which works nicely for ...canceling. But I couldn't find anything similar
> for the back button. Any ideas?



You need to manage it on the server side. There are many ways to do it, just
to mention a pair:
1) the button points to the previous action;
2) implement a history manager that manages the history of called actions
and, when called "back" (e.g. with a "history action") you go back in the
history.

Ciao
Antonio

Re: Implementing a back button without Javascript

Posted by Jeff Miller <jm...@appriss.com>.
If you don't want to add another form element to the page you could take a look at LookupDispatchAction's getKeyMethodMap() method. Extend LookupDispatchAction in your action class. Override the getKeyMethodMap in which you can map your button's keys to methods you create. You could create a mapping for your "prompt.back.button" to a goBack method. In goBack() you can do whatever processing you might need to "undo" things, then return a forward name that you map for it in your struts-config file.


On 3/19/08 9:02 AM, "Dimitris Mouchritsas" <di...@eurodyn.com> wrote:

Hi all,
we're using struts 1.2.4 in our project and I'm trying to implement a
back button for a 3 step registration procedure. The problem is I'd
like to do it without using javascript. I've discovered html:cancel
which works nicely for ...canceling. But I couldn't find anything similar
for the back button. Any ideas?
Thanks

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