1 Reply Latest reply on Nov 26, 2010 1:22 PM by piotrde

    Extracting DTO fields into table

    piotrde

      Hi all,


      I have a little problem with extracting fields from my DTO object into html table using JSF. It is built in a way that I have a backoffice service bean which for the given period of time produces DTO object containing essential informations to show on screen:


      public EmployersPracticesDTO getEmployersPractices(Date dateFrom, Date dateTo);


      Here is how I use it to print data on console:




      private static void printEmployerOfferedPractices(
                     PracticesServiceRemote service, GregorianCalendar cFrom,
                     GregorianCalendar cTo) {
                EmployersPracticesDTO employerPracticesDTO = service
                          .getEmployersPractices(cFrom.getTime(), cTo.getTime());
      
                List<EmployersPracticesDTO.EmployerOfferedPractices> offeredPractices = employerPracticesDTO
                          .getEmployerOfferedPractices();
      
                for (EmployerOfferedPractices p : offeredPractices) {
                     System.out
                               .println("[COMPANY]: " + p.getCompanyName()
                                         + " [NUMBER OF PRACTICES]: "
                                         + p.getNumberOfPracticesDone());
                }
      
           }




      The same I would do in xhtml document but i have not a clue how to reference to DTO...
      (yes, I've read a documentation, but I cannot find anything about mapping non-beans)


      Thank you in advance



        • 1. Re: Extracting DTO fields into table
          piotrde

          Sorry, I've forgotten, here is how my DTO looks like:




          public class EmployersPracticesDTO implements Serializable {
          
               /**
                * needed during serialization
                */
               private static final long serialVersionUID = -1674163395194600978L;
               
               private List<EmployerOfferedPractices> employerOfferedPractices;
               
               public EmployersPracticesDTO() {
                    this.employerOfferedPractices = 
                         new ArrayList<EmployerOfferedPractices>();
               }
               
               public void addEmployerOfferedPractices(
                         EmployerOfferedPractices employerOfferedPractices) {
                    this.employerOfferedPractices.add(employerOfferedPractices);
               }
          
               public List<EmployerOfferedPractices> getEmployerOfferedPractices() {
                    return employerOfferedPractices;
               }
          
               public static class EmployerOfferedPractices implements Serializable {
                    /**
                     * needed during serialization
                     */
                    private static final long serialVersionUID = 7578584034230432388L;
                    
                    private String companyName;
                    private int numberOfDonePractices;
          
                    public EmployerOfferedPractices(String companyName, int numberOfPractices) {
                         this.companyName = companyName;
                         this.numberOfDonePractices = numberOfPractices;
                    }
          
                    public int getNumberOfPracticesDone() {
                         return numberOfDonePractices;
                    }
          
                    
                    public String getCompanyName() {
                         return companyName;
                    }
               }
          }