Announcement Announcement Module
Collapse
No announcement yet.
LocaleChangeInterceptor not working Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • LocaleChangeInterceptor not working

    Hi All,
    I tried for a long time in getting the internationalization to work , but in vain. I have read through all the forums, but still I couldn't get this to work. I use Spring Spring Webflow in my application for UI Rendering.

    I have label_en.properties and label_zh.properties. Text from label_en.properties are always rendered. When I pass URL parameters with zh, nothing is happening and page loads with English language again. Any help is really appreciated. I have used interceptors and handlers as suggested, but still nothing happens. Spring version is 3.0.3 and webflow version is 2.1.1.

    Please find below the details of my code.

    The Web-mvc config file which is included in Spring configuration file is
    ---------------------------------------------------------------------------------------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:webflow="http://www.springframework.org/schema/webflow-config"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-3.0.xsd
    http://www.springframework.org/schema/webflow-config
    http://www.springframework.org/schem...config-2.0.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <!-- Executes flows: the central entry point into the Spring Web Flow system -->
    <webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry"/>

    <!-- The registry of executable flow definitions -->
    <webflow:flow-registry id="flowRegistry"
    flow-builder-services="flowBuilderServices" base-path="/WEB-INF">
    <webflow:flow-location-pattern value="/**/*-flow.xml" />
    <!--<webflow:flow-location path="user/register-flow.xml" />-->
    </webflow:flow-registry>

    <!-- Plugs in a custom creator for Web Flow views -->
    <webflow:flow-builder-services id="flowBuilderServices"
    view-factory-creator="mvcViewFactoryCreator" />

    <!-- ResourceBundle entries -->

    <mvc:annotation-driven/>

    <bean id="messageSource"
    class="org.springframework.context.support.Reloada bleResourceBundleMessageSource">
    <property name="basename" value="classpath:label" />
    <property name="defaultEncoding" value="UTF-8"/>
    </bean>

    <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.Locale ChangeInterceptor">
    <property name="paramName" value="lang" />
    </bean>

    <bean id="localeResolver"
    class="org.springframework.web.servlet.i18n.Cookie LocaleResolver">
    <property name="defaultLocale" value="en" />
    </bean>

    <bean class="org.springframework.webflow.mvc.servlet.Flo wHandlerMapping">
    <property name="flowRegistry" ref="flowRegistry" />
    <property name="defaultHandler">
    <!-- If no flow match, map path to a view to render; e.g. the "/intro" path would map to the view named "intro" -->
    <bean class="org.springframework.web.servlet.mvc.UrlFile nameViewController" />
    </property>
    <property name="interceptors">
    <list>
    <ref bean="localeChangeInterceptor" />
    </list>
    </property>
    </bean>

    <bean id="urlMapping" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="interceptors">
    <list>
    <ref bean="localeChangeInterceptor"/>
    </list>
    </property>
    </bean>

    <mvc:interceptors>
    <bean class="org.springframework.web.servlet.i18n.Locale ChangeInterceptor" >
    <property name="paramName" value="lang" />
    </bean>
    </mvc:interceptors>

    <!-- Configures Web Flow to use Tiles to create views for rendering; Tiles
    allows for applying consistent layouts to your views -->
    <bean id="mvcViewFactoryCreator"
    class="org.springframework.webflow.mvc.builder.Mvc ViewFactoryCreator">
    <property name="viewResolvers" ref="tilesViewResolver" />
    <property name="useSpringBeanBinding" value="true" />
    </bean>

    </beans>
    ---------------------------------------------------------------------------------------------------------

    Invoking parameters, using the below jsp.
    ---------------------------------------------------------------------------------------------------------
    <span style="float: right">
    <a href="?lang=en">en</a>
    |
    <a href="?lang=zh">zh</a>
    </span>
    ---------------------------------------------------------------------------------------------------------

  • #2
    Hi Team,

    Can anyone help on this please ?

    Thanks,Bala

    Comment

    Working...
    X