使用SpringWebFlow转换刷新视图
我正在尝试将本地化添加到使用SpringWebFlow和facelets构建的web应用程序中。我想增加对英语和法语的支持。我已经创建了两个messages\u fr.properties和messages\u en.properties文件 我用于所有jsf页面的模板有以下代码来定义消息包和两个链接来在法语和英语之间切换使用SpringWebFlow转换刷新视图,spring,jsf,internationalization,spring-webflow,Spring,Jsf,Internationalization,Spring Webflow,我正在尝试将本地化添加到使用SpringWebFlow和facelets构建的web应用程序中。我想增加对英语和法语的支持。我已经创建了两个messages\u fr.properties和messages\u en.properties文件 我用于所有jsf页面的模板有以下代码来定义消息包和两个链接来在法语和英语之间切换 <f:loadBundle basename="messages" var="msg" /> ... <h:commandLink id="changeLo
<f:loadBundle basename="messages" var="msg" />
...
<h:commandLink id="changeLocaleFr" action="changeLocale"
class="flag fr">
<f:param name="ln" value="fr" />
</h:commandLink>
<h:commandLink id="changeLocaleEn" action="changeLocale"
class="flag en">
<f:param name="ln" value="en" />
</h:commandLink>
...
我已经设置了一个会话本地解析程序
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />
和一个本地变更拦截器
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="ln" />
</bean>
我将其添加到流处理程序映射中
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<property name="flowRegistry" ref="flowRegistry" />
<property name="interceptors">
<list>
<ref bean="localeChangeInterceptor"></ref>
</list>
</property>
<property name="order" value="0" />
</bean>
在我的流程中,我有一个changeLocale的全局转换
<global-transitions>
<transition on="changeLocale" />
</global-transitions>
所有这些几乎都在起作用。当我点击其中一个链接时,区域设置就改变了。但我没有立即看到更改,我必须手动刷新或导航到另一个视图,以使用新语言重新提交页面。如何在单击链接后立即显示更改?我猜这与处理changeLocale操作时JSF视图根根本没有更改有关。 在处理区域设置更改时,请尝试添加以下代码:
FacesContext context = FacesContext.getCurrentInstance();
context.setViewRoot(context.getApplication().getViewHandler().createView(context, context.getViewRoot().getViewId()));
这样,JSF就被迫刷新所有组件的状态。我猜这与JSF视图根在处理changeLocale操作时没有发生任何更改有关。 在处理区域设置更改时,请尝试添加以下代码:
FacesContext context = FacesContext.getCurrentInstance();
context.setViewRoot(context.getApplication().getViewHandler().createView(context, context.getViewRoot().getViewId()));
这样,JSF将被迫刷新所有组件的状态。很抱歉,我没有其他方法与您联系,这是紧急情况。我有一个关于gwt的问题,你能帮我吗。问题是[这里][1][1]:很抱歉,我没有其他方法与您联系,这是紧急情况。我有一个关于gwt的问题,你能帮我吗。问题是[这里][1][1]: