After changing locale in action mathod with return null as I apologize page should be reload but field with date doesn't change after first click on link for changing locale. I use MyFaces
I have a page where user can set locale and after changing locale I can't get desired format of date just after second time push on link for changing locale. I use bean for localization from this post
I cant understand why in
<h:outputText value="#{newsVar.date}">
<f:convertDateTime pattern="#{msg['date.pattern']}" />
</h:outputText>
!!!! Edited!!! I have some problems with getting id of dataField whem I use facets in mainLayout.xhtml
<f:view locale="#{localeManager.language}">
<div id="wrapper">
<div class="header">
<ui:insert name="header">
<ui:include src="/pages/template/commonHeader.xhtml" />
</ui:insert>
</div>
<div class="content_container">
<ui:insert name="content" />
</div>
</div>
</f:view>
commonHeader is included commandLink
<ui:composition>
<h:form>
<h1>
<h:outputText value="#{msg['header.text']}" />
</h1>
<div class="lang_selector">
<h:commandLink action="#{localeManager.changeLanguage('ru')}"
value="#{msg['header.language.ru']}">
<!-- <f:ajax render=":listGroupId:dateField" />-->
</h:commandLink>
<h:commandLink action="#{localeManager.changeLanguage('en')}"
value="#{msg['header.language.en']}">
<!-- <f:ajax render=":listGroupId:dateField" />-->
</h:commandLink>
</div>
</h:form>
</ui:composition>
And in current page I have next
<ui:composition template="/pages/layouts/mainLayout.xhtml">
<ui:define name="content">
<f:event type="preRenderView" listener="#{news.showNews}" />
<h:form id="listForm" prependId="false">
<h:panelGroup id="listGroupId">
<ui:repeat var="newsVar" value="#{news.newsList}">
<div class="news_item">
<div class="news_title">
<h1>
<h:outputText value="#{newsVar.title}" />
</h1>
<div class="news_date">
<h:outputText id="dateField" value="#{newsVar.date}">
<f:convertDateTime pattern="#{msg['date.pattern']}" />
</h:outputText>
</div>
As you can see a try to get id of "dateField" but that id in different form. I read next article How to JSF 2.0: – render components outside of the form I understand that I should set <h:form id="listForm" prependId="false">
then I can set elementId in <f:ajax/>
without name of form but I get error javax.faces.FacesException - Component with id::listGroupId:dateField not found
.
And I find that: The element which is specified in render must be already present in the client side HTML DOM tree. May be that's why I have this problem
Please, help me... Why is pattern for date changed only from 2nd time?