JSF 2 dynamic ui:include reading old bean field value
I've been scratching my head, trying to think why this no longer works. I've got a page with a dynamic <ui:include src="subpages/#{bean.subpage}.xhtml>
, along with some commandLinks that are supposed to set the value of the subpage bean field. The bean is a session-scoped Spring bean. All's well and good. But when clicking on a commandLink, I'm finding that the <ui:include>
is reading the current value of the subpage field before my action, which sets the field's new value, is called. Given my current code below:
<h:form id="navform">
<h:panelGrid columns="1">
<h:commandLink value="Page 2" action="#{navigateTestBean.navigateToSection('page2')}"/>
<h:commandLink value="Page 3" action="#{navigateTestBean.navigateToSection('page3')}"/>
</h:panelGrid>
</h:form>
<h:panelGroup id="mainArea">
<ui:include src="subpages/#{navigateTestBean.sectionName}.xhtml"/>
</h:panelGroup>
and
@Service
@Scope("session")
public class NavigateTestBean {
private String sectionName;
@PostConstruct
private void doSetup() {
sectionName = "general";
}
public String navigateToSection(String sectionName) {
this.sectionName = sectionName;
return null;
}
public String getSectionName() {
开发者_Python百科 return sectionName;
}
public void setSectionName(String sectionName) {
this.sectionName = sectionName;
}
}
The first time I click a link, to say page2, getSectionName() is called, reads "general", and then navigateToSection() is called. No further getSectionName() is called, so ui:include ends up rendering the general subpage again. The next time I click a commandLink, whether the same or another one, I ultimately get page2 (the current value of sectionName before it's set to its new value) rendered.
I have also tried wrapping the commandLinks in <f:ajax render=":mainArea">
, as noted in one of BalusC's other answers elsewhere, with no change in behavior.
What stupid little thing am I missing? Running on Tomcat 6.0.33 with the EL 2.2 parser, Mojarra 2.0.2 and RichFaces 4. Thanks!
Looks to be a bug in Mojarra 2.0.2. Upgraded to 2.1.3, the latest release in Maven, and the situation is resolved.
精彩评论