[jboss-user] [JBoss Portal] - How can I set the language for all portlets in the portal
rkiesi
do-not-reply at jboss.com
Thu Sep 7 12:32:03 EDT 2006
Hi all,
I try to write a portlet in which a user can select the language of the information displayed in all other portlets. So far I can change the language for each portlet seperately. Please see the code below for details.
The managed Bean:
public class ChangeLocaleBean {
|
|
| private java.lang.String bundleName;
|
| /**
| * Changes the language
| * @param event
| */
| public void changeLocale(ActionEvent event) {
| HtmlCommandLink cl = (HtmlCommandLink)event.getComponent();
| String localeString = (String)cl.getId();
| FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale(localeString));
| }
|
| /**
| *
| * @return bundleName
| */
| public java.lang.String getBundleName() {
| return bundleName;
| }
|
| /**
| *
| * @param bundleName bundleName
| */
| public void setBundleName(java.lang.String bundleName) {
| this.bundleName = bundleName;
| }
|
| }
The JSP:
<%@ page contentType="text/html" isELIgnored="false"%>
| <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
| <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
| <f:loadBundle basename="#{changeLocaleBean.bundleName}" var="bundle" />
|
| <h:form>
| <h:panelGroup id="languageSelector">
| <h:commandLink id="de"
| actionListener="#{changeLocaleBean.changeLocale}">
| <h:graphicImage url="/images/at.gif" alt="#{bundle['language.german']}"
| title="#{bundle['language.german']}" />
| </h:commandLink>
|
| <h:commandLink id="en"
| actionListener="#{changeLocaleBean.changeLocale}">
| <h:graphicImage url="/images/gb.gif"
| alt="#{bundle['language.english']}"
| title="#{bundle['language.english']}" />
| </h:commandLink>
| </h:panelGroup>
| </h:form>
part of the faces-config.xml
<managed-bean>
| <managed-bean-name>changeLocaleBean</managed-bean-name>
| <managed-bean-class>
| at.join2learn.portlet.nodetypemanager.managedBeans.ChangeLocaleBean
| </managed-bean-class>
| <managed-bean-scope>application</managed-bean-scope>
| <managed-property>
| <property-name>bundleName</property-name>
| <property-class>java.lang.String</property-class>
| <value>at.join2learn.portlet.locales.bundle</value>
| </managed-property>
| </managed-bean>
Thanks in Advance
Reinhard
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970137#3970137
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970137
More information about the jboss-user
mailing list