Can't save value of dynamic h:inputText back to the bean

UI Components for JSF
Post Reply
linwh0520
Posts: 8
Joined: 11 Nov 2010, 16:22

01 Jul 2011, 19:16

JSF 1.2 + Primefaces 1.1 in Glassfish 2.1

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>
This code displays 3 input boxes in the screen with correct values(a,b,c). But the value that I entered in the inputbox can't be saved to the bean.

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>
This code dispalys only one inputbox in the screen, with no value in it.

Code: Select all

<c:forEach  begin="1" end="10" step="1" varStatus ="status">
      <h:inputText value="#{status.count}"/>
</c:forEach>
This code is supposed to displays "1 2 3 4 ... 10". But it dispalys only one inputbox in the screen, with no value in it.



How can I work around these bugs? The goal is to save the value changes back to the bean.

Thank you.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 58 guests