1 Reply Latest reply on Jan 3, 2007 7:33 AM by jdijkmeijer

    simple question on update

    jdijkmeijer Newbie

      Hi,

      I've a very simple use case I'm trying to implement but I cant get it to work. Its too simple for words:
      I have a list with a few entities (subjects in my case) and clicking on one of them should bring me to the nextpage where I can make some modifications, and than return to my list to see the modifications in the list.
      To achieve this I made a subjectManagerBean, implement subjectManager; with, among others, the following declarations:

      [file:SubjectManagerBean.java]
       @In(required=false)
       @Out(required=false)
       @DataModelSelection
       private Subject subject;
      
       @DataModel
       List<Subject> subjectList;
      

      In the list page I successfully render the list:
      [file:SubjectList.xhtml]
       <h:dataTable id="subjectList" var="subject"
       value="#{subjectList}"
       rendered="#{subjectList.rowCount > 0}">
      ..
       <h:commandLink value="#{subject.lastname}" action="#{subjectMgr.select}"/>
      

      clicking one the required lastname field I go to the edit page:
      [file:SubjectManagerBean.java]
       public String select() {
       if (subject == null) {
       log.error("subject is null");
       }
       return "selectSubject";
      
       }
      

      the edit page looks something like:
      [file:SubjectEdit.xhtml]
       <h:form id="subject">
       <div class="dialog">
       <table>
      ..
       <s:button id="update" value="update"
       action="#{subjectMgr.persist}"
       rendered="#{not empty subject.firstname}"/>
       <h:commandButton id="update2" value="Save Cmd"
       action="#{subjectMgr.persist}"
       rendered="#{not empty subject.firstname}" />
      

      and the managerbean has the persist method to update the subject: (Although I'm not sure thats needed).
      [file:SubjectManagerBean.java]
       public String persist() {
       if (subject == null) {
       log.error("in persistence subject is null");
       } else {
       log.info("persisting" + subject.getEmail());
       em.merge(subject);
       }
       return "success";
       }
      

      Now I have 2 questions:
      1 the h:commandbutton doesnt do anything, no update, no errors, no messages: nada I can only see the id changing from the db id to '0' why?
      2 the s:button brings me to the persist message only to find out that the subject is null, how does this happen?

      I think its a very simple, elementary question but I've been looking in the docs, faqs etc and couldnt find anything, I'm afraid i'm doing something very stupid here, but nevertheless any help would be greatly appreciated.

      regards,
      Jeroen

      PS
      jboss 4.0.5.GA
      seam 1.1GA
      windows XP sp2
      mysql 5.?