Hi I have a link that can change the language on every page of the website i'm developing. In the struts action I'd like to do the business logic and forward back to the same page. The problem is I can't specify the input page in the struts config file because I don't know the target page.
So how can I find out what the input page was. Is there any struts like way?
Try mapping.getInput() or mapping.getInputForward() (mapping being the variable name of the ActionMapping object passed as a parameter to the execute() method of your Action class). getInputForward() does require that you put an input parameter on your action definition, but I'm not sure if getInput() does or not.
I don't understand your reasoning for not being able to specify an input parameter on your action definition. You don't need to know what page is eventually going to be displayed, you just need to know what action class is going to be called.
I'll try to explain it better. I'd like to implement a link on the toolbar of my web application to switch the user's locale using Struts. But it's not I'm struggling with. I want to return to the page where request came from afterwards. So how can I configure this, since I cannot configure this in the action mapping of struts-config.xml, because simply the request can be sent from any of my jsp's. Returning a 'new ActionForward(mapping.getInput())' from the Action also does not help here, because for the same reason I cannot configure an 'input' in struts-config.xml.
instead of relying on Struts to solve this, can you do this:
Maintain the 'current' page of the user as a session variable. that way, whenever the request to change the language is made, you only have to read the session variable to know which jsp called it and use mapping.findforward() to fwd the request to the right jsp?
Welcome to JavaRanch. We don't have many rules here, but we do have a naming policy which we try to strictly enforce. Please re-read this document and edit your display name in order to comply. For example, your previous name - Pavel Shakhovich - was perfectly acceptable and in line with what we are looking for. Thanks in advance, and we look forward to seeing you around the Ranch.
Hi, there is a struct tag. It might be what you want
Joined: May 12, 2005
Thanks everebody for help. I've solved this problem by storing the previous page in a session. An in change language action I simply form a new ActionForward based on the previous page. It looks like as the fragment of the code below. 1. In all my actions I use this code: