views:

35

answers:

1

I have a JSF/RichFaces setup, and I found this tutorial. I followed it step by step, but I can't manage to get it.

Also: language.jsp is mentioned in the tutorial, can anybody tell me what exaclty it is?

Or if you think this is not an appropiate tutorial and have a better one, please, let me know.

A: 

All the steps in the tutorial are not really needed.
What I did (And it works) is:
1. In loging.xhtm, for instance:

    <f:view locale="#{languageDetails.locale}" >
    <head>
    .....
    <f:loadBundle basename="messages.Messages" var="msg1"/>
    .....
<f:view>
     <h:form>
          <h:panelGrid columns="2">
                <h:outputText value="Select Language"></h:outputText>
                <h:selectOneMenu id="dropdown" value="#{languageDetails.locale}">
                      <f:selectItem itemValue="en" itemLabel="English" />
                      <f:selectItem itemValue="es" itemLabel="Spanish" />
                      <f:selectItem itemValue="de" itemLabel="German" />
                </h:selectOneMenu>
          </h:panelGrid>
          <p><h:commandButton id="change" value="Change Language"
           action="#{languageDetails.changeLanguage}" /></p>


      </h:form>
</f:view>


    </body>
    </f:view>

2.In java source code I also made some changes:

public class LanguageDetails {

    private static String locale = Locale.getDefault().getDisplayLanguage();

      public void setLocale(String locale1) {
        this.locale = locale1;
      }

      public synchronized String getLocale() {
        return locale;
      }

      public synchronized String changeLanguage() {
        return "changed";
      }
}

And that's all.
Hope this could help

mujer esponja