Hi,
To achieve ui:repeat in Java class.
The object to be looped on must be list or an array.
//It is the context called by current threads request
FacesContext context = FacesContext.getCurrentInstance();
// Application instance associated with this web application.
Application application = context.getApplication();
//Here component type will be facelets.ui.Repeat
UIRepeat repeat= (UIRepeat) application
.createComponent(UIRepeat.COMPONENT_TYPE);
//Here the ID is set
repeat.setId("repeatGrid");
//The variable name is set
repeat.setVar("value");
//used to calculate the value for the specified attribute or property name, if any
//Here the value is set for “value” attribute
repeat
.setValueExpression(
"value",
getValueExpression(fc,
"#{valueList.value}"));
You can add “repeat” variable to "parentObject"(parent object) by using
parentObject.getChildren().add(repeat);
This implementation was done for the dynamic population
through methods inside java classes.
You can implement in jsf simply through this.
<ui:repeat var=" value " value=""#{valueList.value}">
<h:outputText value="#{ value }”/>
</ui:repeat>
Thanks.