1 Reply Latest reply on Aug 17, 2008 7:22 PM by Tarek Al-Sitt

    DataModel is returned null after rending and editing

    Tarek Al-Sitt Newbie
      Hello All.
      I'm pretty new to seam. and I wrote a small code but i'm facing a problem with a DataModel List
      the case as follows
      my pages.xml look like this:

      <page view-id="/editCertificates.xhtml" action="#{certificateBean.initCertificates}" >
              <rule if-outcome="certificatesUpdated">
                 <redirect view-id="/listPatches.xhtml"  />
      <page view-id="/listPatches.xhtml">
      <param name="patch.id" value="#{patchHome.id}" converterId="javax.faces.Long" />
                      <rule if-outcome="merged">
                              <redirect view-id="/listPatches.xhtml" />
                      <rule if-outcome="certificatesCreated">
                              <redirect view-id="/editCertificates.xhtml"  />

      the scenario starts as follows
      1- I list the patches in a listPatches.xhtml and within the page there is a link to initialize the certificates relatd to this patch depending on a value within the patch bean,this is all done in PatchHome class using a method called createCertificates as followos
      public class PatchHome extends EntityHome<Patch> {

              private List patches;
              @Out(scope = ScopeType.CONVERSATION, required = false)
              private Patch patchModel;

      public String createCertificates() {
              int size = patchModel.getCertificates().size();
              if(size == 0) {
                      List<Certificate> certs = patchModel.getCertificates();
                      Date date = new Date(System.currentTimeMillis());
                      for (int i = 0; i < patchModel.getFirstYearCCRCount().intValue(); i++) {
                              Certificate c = new Certificate(patchModel, null, date, "testuser", null, null, new Integer((patchModel.getFirstYear().intValue() - 2000)));
      return "certificatesCreated";

      2- The code above works fine and persist the list of certificates related to the page
      3- when the editCertificates.xhtml is rendered depending on the Second Seam Component the got the patchModel object Injected from the above class, but the problem is when i call the  command button after setting some values to the certificates that are already created and only need some fields to be updated the list is returned null
      public class CertificateHome {
              private Patch patchModel;
              private EntityManager entityManager;
              private List fetchedCertificates;
              public void initCertificates() {
                      fetchedCertificates = patchModel.getCertificates();

              public String updateCertificates() {
               // the real problem goes here. because the fetchedCertificates list is null when
               // this method is called.

      the s:button looks like this
      <s:button id="persis" value="Update" action="#{certificateBean.updateCertificates}"/>

      Please Anyone can tell me what am I missing here. what makes the list empty.

      Thanks in advance