2 Replies Latest reply on Nov 29, 2010 7:30 AM by mpula

    TabPanel internationalization.

    mpula Newbie

      I have multilingual web application. On the view where is rich:tabPanel first tab has correct messages (according to language set up in browser), but other tabs always has messages in default language. When I change tab order (another one tab is now first tab) situation repeats, only first tab has correct messages. Does anybody had similar problem? Any ideas what can be wrong?

        • 1. Re: TabPanel internationalization.
          Ilya Shaikovsky Master

          you loading some properties with loadBundle? then use a4j: one instead of f: one tag.

           

          if not the case - show the code.

          • 2. Re: TabPanel internationalization.
            mpula Newbie

            I have already done workaround for this problem. But I am curious why previous version did not work.

             

            Description of the problem.

            Some page (jsf + faceletes):

            <a4j:form style="clear:both">                  
                        <rich:tabPanel headerAlignment="right" switchType="ajax">
                            <rich:tab label="#{msgs.label1}"
                                      action="#{someBean.someAction}">
                                <ui:include  src="./somePage.xhtml">                        
                                </ui:include>
                            </rich:tab>
                            <rich:tab label="#{msgs.label2}"
                                      action="#{someBean2.someAction2}">
                                <ui:include src="./somePage2.xhtml">                        
                                </ui:include>
                            </rich:tab>    
                    </rich:tabPanel>
            </a4j:form>
            

            On somePage.xhtml and somePage2.xhtml I have a few rich:comboBox components. For this combobox I have converter:

             

            public class PrepaidTypeConverter implements Converter {
                
                private static final MessagesBundleManager msgs = MessagesBundleManager.getInstance(); //loads messages from bundle    
                private String ALL_ITEMS_LABEL = msgs.getMessage("combo_box_all");
            
                @Override
                public Object getAsObject(FacesContext context, UIComponent component, String value) {
                    //some code
                }
            
                @Override
                public String getAsString(FacesContext context, UIComponent component, Object value) {
            
                    if ((value != null) && (value instanceof SomeType)) {
                        SomeType object = (SomeType) value;
                        String key = object.getName();
                        return msgs.getMessage(key);
                    }
            
                    return ALL_ITEMS_LABEL;
                }
            
            }
            

            Now the problem is only when comboBox has not have a selected value. Private field ALL_ITEMS_LABEL have correct value only for first tab in tabPanel. When I change tab to other panel ALL_ITEMS_LABEL have value read from default bundle.

            When I change tabPanel switchType to client then is OK. But to have still ajax switchType I remember locale in some session bean wher user logs on. And modify converter:

             

            private SessionBean sessionBean = (SessionBean) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("sessionBean");
            private String ALL_ITEMS_LABEL = msgs.getMessage("combo_box_all", sessionBean.getLocale());
            

             

            Could someone tell me why ALL_ITEMS_LABEL on other tabPanel than first is always in default language (in my first solution)?