I have a ui:repeat inside a h:panelgroup, and a f:ajax outside the panel. The f:ajax click event triggers a render on the h:panelgroup. When I load the page the repeater shows my 5 items on the list. When I click the button for the first time, the h:panelgroup doubles to 10 items, every subsequent click just refreshes the first 5 items on the panel (as it should). What am I doing wrong? shouldn't the render event always just refresh the panel with the repeater in it?
BEAN:
@ManagedBean(name = "TestBean")
@RequestScoped
public class TestBean {
private List testStrings;
public TestBean() {
Random rn = new Random(System.currentTimeMillis());
testStrings = Arrays.asList(rn.nextInt(),rn.nextInt(),rn.nextInt(),rn.nextInt(),rn.nextInt());
}
}
public List getTestStrings() {
return testStrings;
}
public void setTestStrings(List testStrings) {
this.testStrings = testStrings;
}
JSF:
<h:commandButton value="Refresh">
<f:ajax event="click" render="testPanel"></f:ajax>
</h:commandButton>
<p>
<h:panelGroup id="testPanel">
<ui:repeat var="option" value="#{TestBean.testStrings}" varStatus="status">
<p>
<h:outputText value="#{option}"></h:outputText>
</p>
</ui:repeat>
</h:panelGroup>
</p>
I am using mojarra 2.1 I think.
Thanks.
ANSWER
The problem doesn't happen if I remove the <p>...</p>
and reaplace it with <h:outputText value="#{option}"></h:outputText><br/>
....` but on my code I had `
.....`, and if I take any of those two `
`s out then it works fine.