1 Reply Latest reply on Feb 21, 2012 3:11 AM by vata2999

    Why dataTable can not show any data

    vani.li

      @Stateless

      @Name("sayhello")

      public class SayHelloActionImp implements SayHelloInterface {

        private int columnId;

        @In(required=false)

        @Out

        private Person person;

       

        @Out(required=false)

        private List<Person> users;

       

        @PersistenceContext

        private EntityManager em;

       

        /* (non-Javadoc)

        * @see com.session.SayHelloInterface#sayHello()

        */

        public void sayHello()

        {

        em.persist(person);

        person = new Person();

        System.out.println("Save done!");

        users = em.createQuery("select p from Person p").getResultList();

         }

      }

       

      When I configured page.xml to let it re-direct to another xhtml page,

       

      code in that page is like:

       

      <h:dataTable value="#{users}" var="user">

          <h:column>

          <h:outputText value="#{user.name}" />

          </h:column>

      </h:dataTable>

       

      None Result showed on screen, Why? (BTW, persist action has sucessfully finished)

        • 1. Re: Why dataTable can not show any data
          vata2999

          Hi,

           

          in this case u need two more annotation in order to build list

           

           

          @DataModel
          @Out(required=false)
            private List<Person> users;
          
          @Factory("users")
          void populateUserList(){
                users = em.createQuery("select p from Person p").getResultList();
          }