OK. Here is a highly simplified case of the problem (source included):
The custom component 'repeat' will simply iterate through its children and
renders them.
Usage:
<netx:repeat binding="#{testBean.htmlRepeat}">
<h:outputText value="Child-1"/>
<h:outputText value="Child-2"/>
</netx:repeat>
Renderer output:
[begin - Child-1Child-2 - end]
BackingBean:
The repeat component is bounded to a backing bean like so:
public class TestBean {
private HtmlRepeat htmlRepeat;
public HtmlRepeat getHtmlRepeat() {
return null;
}
public void setHtmlRepeat(HtmlRepeat htmlRepeat) {
this.htmlRepeat = htmlRepeat;
}
// -- action method
public String formSubmitted() {
System.out.println("formSubmitted()");
HtmlOutputText child = new HtmlOutputText();
child.setValue("Child-3");
htmlRepeat.getChildren().add(child);
return null;
}
}
and the form is submitted using <h:commandButton value="Submit" action
="#{testBean.formSubmitted}"/>
The formSubmitted() method simply adds a child to htmlRepeat like so
htmlRepeat.getChildren().add(child). Note that the child is added as the
last child to the children list. But when the response is renderered, the
newly added child appears at the beginning.
Expected Output:
[begin - Child-1Child-2Child-3 - end]
Actual Output:
[begin - Child-3Child-1Child-2 - end]
Attachments:
1. jsf-repeat.jar - Deployable JSF component packaged as jar (contains
.java files, faces-config.xml and facelet taglib for the custom
component).
Download >> http://keerthi.linux.googlepages.com/jsf-repeat.jar
2. TestRepeat.xhtml - Facelet view using the <netx:repeat/> custom
component
Download >> http://keerthi.linux.googlepages.com/TestRepeat.xhtml
Note: The component requires facelets and so no TLD has been defined.
Tested on myfaces1.2.6/Tomcat 6.20