1 Reply Latest reply on Apr 10, 2008 1:33 PM by Damian Harvey

    Will the DataModel save data to db automatically?

    Anatorian Su Newbie
      xhtml:
      <h:form>
      <rich:dataTable value="#{action.contracts}" var="c">
       <h:column>
         <h:inputText value="#{c.name}" />
       </h:column>
      </rich:dataTable>
       <h:commandButton action="#{action.save()}" value="save" />
      </h:form>
      
      Action.java
      @Name("action")
      @Scope(ScopeType.CONVERSATION)
      public class Action {
        @In
        private EntityManager em;
      
        @DataModel 
        private List<contract> contracts;
      
        @Create
        @Begin
        public void create(){
          this.contracts = findAllConracts();
        }
      
        public void findAllContracts() {
          em.createQuery("from Contract ").getResultList();
        }
      
        @End
        public void save() {
          ;//I don't do anything here
        }
      }
      
      I edit the name and press save button, the new names were saved to the database. But I didn't do anything like "em.merge(..)", how can it save it?  Does seam save datamodel automatically ?