以下代码不会重新呈现表单:
xhtml:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
template="/WEB-INF/templates/default.xhtml">
<ui:define name="content">
<h:form id="form">
<rich:panel header="My Header">
<h2>
<h:outputLabel value="#{tournamentBean.mode}" />
</h2>
<a4j:commandButton value="Toggle"
action="#{tournamentBean.toggleMode()}" render="form" />
</rich:panel>
</h:form>
</ui:define>
</ui:composition>
豆:
import java.io.Serializable;
import javax.faces.view.ViewScoped;
import javax.inject.Named;
@SuppressWarnings("serial")
@Named("tournamentBean")
@ViewScoped
public class TournamentBean implements Serializable {
private String mode = "A";
public String getMode() {
return mode;
}
public void toggleMode() {
if (this.mode.equals("A"))
this.mode = "B";
else
this.mode = "A";
}
}
我使用的是 Wildfly 8.0,因此使用的是 JSF 2.2。每次单击按钮时都会调用方法 toggleMode。在 IE 11 中,它从不重新呈现表单。在 Chrome 中,它可以工作两次,但不会更多次。
我错过了什么?