Reputation: 2332
Update via ajax seems to work fine but I can't get richfaces polling working. To be precise: output element with id someoutput2 doesn't get updated after 1000ms by a4j:poll element Here is the code of the page:
<h:body>
<h:form id="baseForm">
<h:outputText value="Input field"/>
<br/>
<h:inputText value="#{valueBean.value}">
<f:ajax event="keyup" render="baseForm:someOutput"/>
</h:inputText>
<br/>
<br/>
<h:outputText value="Updated via AJAX:" style="color:red"/>
<br/>
<h:outputText id="someOutput" value="#{valueBean.value}" />
<br/>
<h:outputText value="Updated via Polling:" style="color:green"/>
<br/>
<!-- Polling target -->
<h:outputText id="someOutput2" value="#{valueBean.value}" />
</h:form>
<a4j:region>
<h:form id="pollForm">
<a4j:poll id="poll" interval="1000" timeout="500" enabled="true" reRender="pollForm:poll baseForm:someOutput2"/>
</h:form>
</a4j:region>
</h:body>
Here is the code of the value bean (nothing fancy here):
@ManagedBean
@SessionScoped
public class ValueBean {
private String value = "";
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
Upvotes: 1
Views: 456
Reputation: 3884
You cannot update components such as <h:outputText>
directly, you have to call the reRender on their parent. In this case you'd probably want to wrap the output in <a4j:outputPanel>
and rerender the panel.
Upvotes: 2