4 Replies Latest reply on Oct 29, 2007 12:27 PM by pmuir

    clickable dataTable problem

    asookazian

      So I have a clickable dataTable that's based on a join of two tables. There is a submit button for each row of the dataTable. I can't use the @DataModelSelection annotation (commented below) b/c the List does not consist of only one Entity class, it's based on two.

      How can I identify which row needs to be updated and get all the necessary data for the 2nd table to be persisted to DB? 1st table is read-only. sounds like @DataModelSelection is out of the question here (Java generics does not allow me to specify more than one type per Collection).

      any help much appreciated, otherwise I will resort to Seam remoting/ajax call onclick of submit button per row...

      code snippet from SFSB:

      @DataModel
       private List myAuditList;
      
       @DataModelSelection
       //private TblSecurityAuditWorking tblSecurityAuditWorking;
      
       @Factory("myAuditList")
       public void find()
       {
      
       log.info("in find(): user.getUserId() = " + user.getUserId());
       log.info("in find(): user.getBillingId() = " + user.getBillingId());
      
       int employeeId;
      
       if (!networkId.equals("")) { //user entered a networkId from UI to run for another person, so get new guy's billingId
      
       List myList = em.createQuery("from User u where u.networkId = :networkId").setParameter("networkId", networkId).getResultList();
       User newUser = (User)myList.get(0);
      
       employeeId = newUser.getEmployeeId().intValue();
      
       myAuditList = em.createQuery("SELECT gem, tsaw "+
       "FROM TblSecurityAuditWorking tsaw, "+
       "GlobalEmployeeMaster gem "+
       "WHERE tsaw.id.siteId = gem.id.siteId "+
       "AND tsaw.id.employeeNumber = gem.id.employeeNumber "+
       "AND tsaw.reportToId = :employeeId")
       .setParameter("employeeId", employeeId)
       .getResultList();
       }
      }


        • 1. Re: clickable dataTable problem
          pmuir

           

          "asookazian" wrote:
          So I have a clickable dataTable that's based on a join of two tables. There is a submit button for each row of the dataTable. I can't use the @DataModelSelection annotation (commented below) b/c the List does not consist of only one Entity class, it's based on two.


          Don't forget your class has an inheritance hierachy.

          How can I identify which row needs to be updated and get all the necessary data for the 2nd table to be persisted to DB? 1st table is read-only. sounds like @DataModelSelection is out of the question here (Java generics does not allow me to specify more than one type per Collection).


          Page parameters?

          • 2. Re: clickable dataTable problem
            asookazian

            thx bro. I'll look into this.

            • 3. Re: clickable dataTable problem
              asookazian

               

              "pete.muir@jboss.org" wrote:
              "asookazian" wrote:
              So I have a clickable dataTable that's based on a join of two tables. There is a submit button for each row of the dataTable. I can't use the @DataModelSelection annotation (commented below) b/c the List does not consist of only one Entity class, it's based on two.


              Don't forget your class has an inheritance hierachy.

              How can I identify which row needs to be updated and get all the necessary data for the 2nd table to be persisted to DB? 1st table is read-only. sounds like @DataModelSelection is out of the question here (Java generics does not allow me to specify more than one type per Collection).


              Page parameters?


              when you refer to inheritance hierarchy, are you referring to the two entity classes (sub-classing one from the other, which doesn't make sense in this case b/c they're unrelated in terms of one is not a shape and one is not a rectangle, or one is not a person and one is not a manager, etc.).

              or are you referring to the SFSB class?

              i'm thinking you're referring to the two JPA entities...

              • 4. Re: clickable dataTable problem
                pmuir

                You said you can't use @DataModelSelection because of two different classes. At its most basic, how about

                @DataModelSelection Object selectedFoo;