PDA

View Full Version : i18n problem on login page


PascalAlberty
Feb 1st, 2008, 02:08 PM
Hi all,

I'm currently using (successfully) a localeChangeInterceptor and CookieLocaleResolver to allow users to choose their locale.


<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeI nterceptor">
<property name="paramName" value="locale"/>
</bean>

<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleR esolver">
<property name="defaultLocale" value="en"/>
<!-- 30 days -->
<property name="cookieMaxAge" value="2592000"/>
</bean>


The locale is stored in a cookie and the application is well translated.

But I have one page which is not translated (default locale is used). This page is the login (acegi) page.

Probably because this page is not a view (there is no controller) but a simple jsp page, messages are not translated.

Any idea ?

Thanks a lot

jonnio
Feb 1st, 2008, 06:15 PM
Make acegi use the spring view dispatcher and/or use the <spring:message tags in your login page so the locale/property stuff is taken care of for you.

PascalAlberty
Feb 2nd, 2008, 02:53 AM
The login page is using fmt tags like the other pages.
This page is also decorated like the other pages.

How can I make acegi use the view dispatcher ?

Thanks for your reply

joshk
Feb 4th, 2008, 04:21 AM
Hi Pascal,

jonnio is right, you can get Acegi to use the request dispatcher for login and logoff page requests.

I will assume that your web app is only mapping .htm files to the requestdispatcher eg.


<servlet-mapping>
<servlet-name>acegi-sampling</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>


In the exceptionTranslatorFilter bean there is an area to declare an authenticationEntryPoint. In the authenticationEntryPoint you can set the loginFormUrl to be anything you want, be it a simple file or a url which is handled by spring mvc (or alike).

eg.

<bean class="org.acegisecurity.ui.webapp.AuthenticationProcessi ngFilterEntryPoint">
<property name="loginFormUrl" value="/login.htm" />
<property name="forceHttps" value="false" />
</bean>

<bean name="/login.htm" class="org.springframework.web.servlet.mvc.UrlFilenameVie wController" />


I hope this helps

Josh

PascalAlberty
Feb 4th, 2008, 08:03 AM
Thanks both of you. It works well now !

UrlFilenameViewController was the missing part.

I simply configured the following bean

<bean id="urlFilenameViewController" class="org.springframework.web.servlet.mvc.UrlFilenameVie wController"/>

add a specific mapping for the login page


<prop key="/login.html">urlFilenameViewController</prop>


change the loginFormUrl property in my authenticationProcessingFilter

<bean id="exceptionTranslationFilter" class="org.acegisecurity.ui.ExceptionTranslationFilter">
<property name="authenticationEntryPoint">
<bean class="org.acegisecurity.ui.webapp.AuthenticationProcessi ngFilterEntryPoint">
<property name="loginFormUrl" value="/login.html" />
<property name="forceHttps" value="false" />
</bean>
</property>
</bean>

and move my jsp file from the webapp root to the views directory

thanks again !