0 Replies Latest reply on Nov 22, 2008 8:03 PM by Val Sw

    Need help in getting reference of entity values from Home

    Val Sw Expert
      Hi,

      I have few entities hierarchy is QuantExperiment > Reagent > Treatment.

      I need help in getting reference of Treatment entity data in QuantExperiment to display values in QuantExperimentEdit.xhtml using rich datatable.
      Getting reference of reagent is fine as it is directly associated with QuantExperiment.

      I tried many ways in getting Treatment details in QuantExperiment... but no luck, rich tab for treatment always say "There are no treatment associated with this reagent."

      Pls help... here are the details :
      ---------------------------------
      @Name("quantExperimentHome")
      public class QuantExperimentHome extends EntityHome<QuantExperiment> {

           @In(create = true)
           ProjectHome projectHome;
           
           @In(create = true)
           TreatmentHome treatmentHome;
           .... other methods generated by seam generate-ui.....
           public List<Reagent> getReagent() {
                return getInstance() == null ? null : new ArrayList<Reagent>(
                          getInstance().getReagent());
           }
           
           //Added to get Treatment details in QuantExperimentEdit.xhtml
           public List<Treatment> getTreatment() {
                System.out.println("**** QEHome.getTreatment(), ENTERED.....");
                return reagentHome.getInstance() == null ? null : new ArrayList<Treatment>(
                          reagentHome.getInstance().getTreatment());
           }     
      }

      QuantExperimentEdit.xhtml
      -------------------------
      This is OK I am getting the values of reagent
      <rich:tab label="reagent">
           <div class="association" id="reagentChildren">
                <h:outputText value="There are no reagent associated with this quantExperiment."
                             rendered="#{empty quantExperimentHome.reagent}"/>
           
                <rich:dataTable value="#{quantExperimentHome.reagent}"
                                  var="reagent"
                            rendered="#{not empty quantExperimentHome.reagent}"
                          rowClasses="rvgRowOne,rvgRowTwo"
                                    id="reagentTable">          
                     <h:column>
                          <f:facet name="header">PType</f:facet>
                          <h:outputText value="#{reagent.PType}"/>
                     </h:column>
                     .....
      </rich:tab>
      ------------------
      Trying to get the values of treatment
      -------------------------------------
      <rich:tab label="treatment">
      <div class="association" id="treatmentChildren">
           <h:outputText value="There are no treatment associated with this reagent."
                        rendered="#{empty reagentHome.treatment}"/>//NEED TO HANDLE HERE
           
           <rich:dataTable value="#{reagentHome.treatment}" //NEED TO HANDLE HERE
                             var="treatment"
                       rendered="#{not empty reagentHome.treatment}" //NEED TO HANDLE HERE
                     rowClasses="rvgRowOne,rvgRowTwo"
                               id="treatmentTable">          
                <h:column>
                     <f:facet name="header">note</f:facet>
                     <h:outputText value="#{treatment.note}"/>
                </h:column>
                ......
      <rich:tab>
      --------------------------
      @Entity(name = "QuantExperiment")
      public class QuantExperiment {....

      protected List<Reagent> reagent;
      @OneToMany(cascade = {CascadeType.ALL}, mappedBy="quantExperiment")

      public List<Reagent> getReagent() {
           if (reagent == null) {
                reagent = new ArrayList<Reagent>();
           }
      return this.reagent;
      }
      --------------------------
      @Entity(name = "Reagent")
      public class Reagent
          implements Equals, HashCode, ToString{
           .....
      protected List<Treatment> treatment;
      @OneToMany(cascade = {CascadeType.ALL}, mappedBy="reagent")
          public List<Treatment> getTreatment() {
              if (treatment == null) {
                  treatment = new ArrayList<Treatment>();
              }
              return this.treatment;
          }
      -------------------------