1 Reply Latest reply on Jan 30, 2009 6:25 AM by nbelaevski

    <h:inputText> won't update domain values if it's in <a4j:rep

    freemant

      Hi,

      Below is some simple code showing the problem. A list of items are displayed using a <a4j:repeat>. Each item has a name (string). It will display its name and allow the user to set it using an <h:inputText> and a <a4j:commandButton>. However, even though the action method will be called, the setter is never called. Any idea? Thanks!

      f1.xhtml:
      
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:a4j="http://richfaces.org/a4j">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <title>Insert title here</title>
      </head>
      <body>
      <a4j:repeat value="#{foo.list}" var="item">
       <h:outputText id="n" value="#{item.name}" />
       <h:form>
       <h:inputText value="#{item.name}" />
       <a4j:commandButton action="#{item.action}" reRender="n" />
       </h:form>
      </a4j:repeat>
      </body>
      </html>
      
      Foo.java:
      
      package test;
      
      import java.util.ArrayList;
      import java.util.List;
      
      import javax.webbeans.Named;
      import javax.webbeans.SessionScoped;
      
      @Named
      @SessionScoped
      public class Foo {
       private List<Item> list;
      
       public Foo() {
       list = new ArrayList<Item>();
       list.add(new Item());
       list.add(new Item());
       list.add(new Item());
       }
       public List<Item> getList() {
       return list;
       }
      }
      
      
      public class Item {
       private String name = "Hi";
      
      
       public String action() {
       System.out.println("action called");
       return null;
       }
      
      
       public String getName() {
       return name;
       }
      
      
       public void setName(String name) {
       System.out.println("setter called");
       this.name = name;
       }
      
      }