我正在使用JBoss Wildfly 8.2.0并注意到我的页面上调用了<f:viewParam>
两次:
豆:
@Named
@javax.faces.view.ViewScoped
public class MessageBean implements Serializable {
private String message;
private int count;
public String getMessage() {
return message;
}
public void setMessage(String message) {
System.out.println("setting message");
this.message = message;
}
public void increment() {
this.count++;
}
public int getCount() {
return count;
}
}
XHTML:
<!DOCTYPE html ...>
<html ...>
<f:metadata>
<f:viewParam name="message" value="#{messageBean.message}" />
</f:metadata>
<h:head>
<title>Message</title>
</h:head>
<h:body>
<h:form>
<h:outputText value="#{messageBean.message} (#{messageBean.count} time(s))" />
<h:commandButton value="increment">
<f:ajax render="@form" listener="#{messageBean.increment}" />
</h:commandButton>
</h:form>
</h:body>
</html>
我不明白为什么AJAX请求会触发<f:viewParam>
,为什么只触发第一个。
答案 0 :(得分:3)