The number of h:inputText is dynamic. The value of each h:inputText has to be saved back to the bean. None of <ui:repeat> and <c:foreach> works...
Code: Select all
private List<String> strs;
public MyClass() //constructor
{
strs = new ArrayList<String>();
strs.add("a");
strs.add("b");
strs.add("c");
}
public List<String> getStrs()
{
return strs;
}
public void setStrs(List<String> strs)
{
this.strs = strs;
}
public void save(ActionEvent event)
{
for(String str : strs)
System.out.println(str);
}
Code: Select all
<ui:repeat value="#{myClass.strs}" var="str" >
<h:inputText value="#{str}>
</ui:repeat>
Note: "varStaus" of ui:repeat doesn't work with JSF 1.2
Code: Select all
<c:forEach items="#{myClass.strs}" var="str" >
<h:inputText value="#{str}>
<c:forEach>
Code: Select all
<c:forEach begin="1" end="10" step="1" varStatus ="status">
<h:inputText value="#{status.count}"/>
</c:forEach>
How can I work around these bugs? The goal is to save the value changes back to the bean.
Thank you.