You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Alex Rodriguez Lopez <al...@flordeutopia.pt> on 2010/03/10 12:15:58 UTC

Changing locale and retaining previous query url params

Hi!

I have the following code in a tile I use on nearly every page of my app:

<s:if test="%{#request.locale.language == 'pt'}">
														<a href="<c:url value="">
<c:param  name="request_locale"
	 value="en" />
</c:url>">
													<img alt="en" src="<c:url value="/images/icon_en.png" />" 
/></a>
										</s:if>												<s:else>
														<a href="<c:url value="">
<c:param  name="request_locale"
	 value="pt" />
</c:url>">
															<img alt="pt" src="<c:url value="/images/icon_pt.png" />" 
/></a>
													</s:else>

So this is basically a toggle between english and portuguese. It works 
well, with the value url empty on <c:url value=""> it appends the 
request_locale param to the current url and the i18n interceptor changes 
locale. But the "request_locale" parameter is the only parameter on the 
new page, so I lost all info of parameters that where on the original 
page prior to changing locale.

For example:

- The user is viewing /user/user_input.action?id=7 (editing the user 
with id=7) and decides to change language, so clicks on the button to 
change it.

- Rendered page: /user/user_input.action?request_locale=en
The new page is in english as espected, but because the url lost the id 
param now the action thinks a new user is to be created, instead of 
editing the user id=7.

So how can I keep the olod params when changing locales?

Help appreciated!

Alex

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