下面的代码不会重新呈现形式:JSF呈现不起作用
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中,它可以运行两次,但不会更多次。
我错过了什么?
虽然'render =“form”'应该可以工作,尽管只有RichFaces,因为它使用'UIComponent#findComponent()'方法来定位组件,所以它显然是低效的,并且'render =“@form”'应该总是用于重新渲染当前表单。 – skuntsel
显示您的“/WEB-INF/templates/default.xhtml”,它是否可能包含的附加h:表单。 –
Andrey
感谢您的提示。 “来自”的“render =”@没有帮助。而default.xhtml非常简单。没有形式或任何特别的东西 – Dave