I wonder if this problem is the same as PORTLETBRIDGE-100
<https://issues.apache.org/jira/browse/PORTLETBRIDGE-100>
(https://issues.apache.org/jira/browse/PORTLETBRIDGE-100):
The first page of the JSF sample CarDemo has you set the locale for
the demo. You choose a language/region and the rest of the views use
strings earmarked for the language of the locale. In the portlet
case this fails -- you always use the English/default locale. This
is because the demo relies on an ActionHandler to set the locale of
the ViewRoot of the current view -- which subsequently is migrated
(by Faces) during the createView of the view the action handler
navigates to. When you render the subsequent view it uses this
locale. In the portlet case because render happens in a separate
request -- we rely on the bridge to cache the viewroot from the end
of the action and preset set it as the current viewRoot prior to
running the lifecycle. Well Faces has code in its restoreView phase
that if the ViewRoot was preset then it resets its locale to the
preferred one from the current request. I.e. we lose the locale we
wanted (that was set when the view was created at the end of the
action). To fix this, cache the locale in the beforePhase (of
restoreView) if using the preset ViewRoot and restore it in the
afterPhase.
What version of the bridge are you using? If P1.0B and its beta (or
before) then the above bug exists (or P2.0B alpha and before). Anyway,
I would suggest retrying with a new(er) bridge. Either build from the
trunk, wait a few days as we are in the processing of pushing the 1.0.0
release, or grab what we are pushing from our staged artifacts at:
http://people.apache.org/~mfreedman/portlet-bridge/
Let me know if this fixes it. If it doesn't please log a JIRA which
includes additional information describing the appserver and portal
server/container you are using, specific version information for all,
and (if possible) a small sample JSF app I can "portletize" so I can
deploy locally and debug.
-Mike-
On 7/1/2010 8:37 AM, Yves Deschamps wrote:
Hi at all,
I have this view and this methods in controller , all is fine in
servlet mode but in portlet mode:
- the locale is not immedialty rendered (next page is ok)
- the "reset" change also the locale (in "en" where i am in "fr")
without sense for me.
-----------------------------------------------------------------------
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad" prefix="tr"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh"%>
<f:view locale="#{commonController.locale}">
<f:loadBundle basename="MessageResources" var="msg" />
<tr:document title="#{msg['DIRECTORY.TEXT']}">
<f:facet name="metaContainer">
<link rel="apple-touch-icon" href="images/touchicon.png">
<meta name="viewport" content="initial-scale=1.0,
maximum-scale=1.0, user-scalable=0" />
<link href="./minimal/minimal.css" rel="stylesheet"
type="text/css" />
</f:facet>
<tr:form id="home">
<tr:panelHeader id="panelHeader" styleClass="toolbar"
text="#{msg['DIRECTORY.TEXT']}">
<tr:commandLink id="reset" styleClass="resetButton"
text="#{msg['CANCEL.TEXT']}"
actionListener="#{commonController.reset}" />
<tr:commandLink styleClass="loginButton" action="login"
rendered="#{not commonController.userAuthenticated
and not commonController.portletMode}"
immediate="true" />
<tr:commandLink styleClass="logoutButton"
actionListener="#{commonController.logout}"
rendered="#{commonController.userAuthenticated and
not commonController.portletMode}"
immediate="true" />
<tr:commandLink id="fr" styleClass="frButton"
actionListener="#{commonController.setLocaleFrench}" immediate="true" />
<tr:commandLink id="en" styleClass="enButton"
actionListener="#{commonController.setLocaleEnglish}" immediate="true" />
</tr:panelHeader>
<tr:outputText styleClass="user" value="#{msg['USER.TEXT']}
#{commonController.user}"
rendered="#{commonController.userAuthenticated and not
commonController.portletMode}" />
<tr:panelList styleClass="panelList">
<tr:inputText id="name"
value="#{commonController.name}" required="true" label="">
<f:validator validatorId="nameValidator" />
</tr:inputText>
<tr:commandLink text="#{msg['STAFF.TEXT']}"
action="persons" />
<tr:commandLink text="#{msg['STUDENTS.TEXT']}"
action="students"
rendered="#{commonController.userAuthenticated}" />
<tr:commandLink text="#{msg['ENTITIES.TEXT']}"
action="entities" />
<tr:goLink text="#{msg['FACULTY_WEB_PAGE.TEXT']}"
destination="#{commonController.facultyWebPageUrl}" />
</tr:panelList>
</tr:form>
</tr:document>
</f:view>
---------------------------------
/**
* @param actionEvent
* @return navigation String.
*/
public String setLocaleFrench(ActionEvent actionEvent) {
FacesContext context = FacesContext.getCurrentInstance();
context.getViewRoot().setLocale(new Locale("fr"));
locale = "fr";
logger.info("Language: fr");
return "home";
}
/**
* @param actionEvent
* @return navigation String.
*/
public String setLocaleEnglish(ActionEvent actionEvent) {
FacesContext context = FacesContext.getCurrentInstance();
context.getViewRoot().setLocale(new Locale("en"));
locale = "en";
logger.info("Language: en");
return "home";
}
/**
* @return the locale
*/
public String getLocale() {
return locale;
}
/**
* @param actionEvent
* @return navigation String.
*/
public String reset(ActionEvent actionEvent) {
name = null;
logger.info("Action: reset");
return "home";
}