Reputation: 1571
I'm using JBoss Wildfly 8.2.0 and noticed that <f:viewParam>
is called twice on my page:
Bean:
@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>
I don't understand why AJAX requests are triggering the <f:viewParam>
and why only the first one.
Upvotes: 3
Views: 474
Reputation: 1108802
This is caused by statefulness of the <f:viewParam>
.
JSF utility library OmniFaces has solved this with its <o:viewParam>
.
Upvotes: 3