aspose file tools*
The moose likes Struts and the fly likes Implementing Dynamic return button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Implementing Dynamic return button" Watch "Implementing Dynamic return button" New topic
Author

Implementing Dynamic return button

Graham VMead
Ranch Hand

Joined: Sep 22, 2003
Posts: 154
Hi
This has all the making of a stupid question but here goes.

I have a page which can be accessed from many other pages. I want to implement a return button so that pressing it causes the page to forward back to where it came from.

I've thought of each start page having an action mapping with a parameter of the start path

e.g screen 1 submit maps to an action with a parameter of screen 1's path
screen 2 submit maps to an action with a parameter of screen 2's path etc.

Setting a hidden field on the target screen and use this to get back to where you came from when you press the return button, e.g press return find the value of the hidden field and forward back to this!

Whew, is there a nicer way of doing this in struts?

TIA Graham
Ergin Er
Ranch Hand

Joined: Sep 06, 2005
Posts: 60
When you implement the button as a submit button (e.g. <html:submit property="button">
you could add a value to it that contains the action path it's supposed to do.
And you can fill that value by extracting it from the form property where you put in the action path on loading the page. So just use your form to store the different actions.
Then in your action you can just read and execute required the action directly.
Or am I just talking rubbish here?
Rich Walton
Greenhorn

Joined: Sep 16, 2005
Posts: 4
dont know if this fits your requirement, but how about using some javascript?

that will give you a link that when you click will take you back
Graham VMead
Ranch Hand

Joined: Sep 22, 2003
Posts: 154
Hi Ergin, Rich,

Thanks for the answers.

Rich I cant guarantee that javascript will be enabled, and also I may need the return to forward to the action of the page to return to rather than just doing a back.

Ergin, I could be talking rubbish but won't the submit button send a request path based on whats defined as the action on the html:form tag in the page containing the return button?

I suppose my question really is how do I get the path of screen 1 to be sent the page containing the return. Then I need to get hold of this when I press the submit button.

I could put it in the session but that doesn't seem right

Graham
[ September 16, 2005: Message edited by: Graham VMead ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Implementing Dynamic return button