3 Replies Latest reply on Oct 17, 2008 4:38 AM by elenctic87

    Specify fields in query and use in datatable?

    brodequin.al.green.vec.virginia.gov

      Is it possible to specify fields in a query and use those same fields in a datatable?


      Bean:


      
           @Factory("acertRequests")
      
           public void requestList(){
      
                String requestQuery = "select t.acertNumber, t.acertTitle from Task t";
      
                acertRequests = (List<Task>) em.createQuery(requestQuery).getResultList();
      
           }
      
      



      View:


      
           <h:dataTable id="table1" value="#{acertRequests}" var="req">
      
                <h:column><h:outputText value="#{req.acertNumber}" /></h:column>
      
                <h:column><h:outputText value="#{req.acertTitle}" /></h:column>     
      
           </h:dataTable>
      
      



      I get the error "java.lang.NumberFormatException: For input string: "acertNumber" with the above example.


      Of course, everything works fine when using select t from Task t. I need to specify field names because I will need to get distinct acertNumber values from the db (select distinct t.acertNumber, t.acertTitle from Task t).


      Any ideas? I've tried just about everything in the value attribute of h:outputText without success. Not sure where to go next.