0 Replies Latest reply on Jan 7, 2008 4:15 PM by Vikram Chhetry

    ejb-ql join and h:dataTable

    Vikram Chhetry Newbie

      Hi All,
      I have a search user page where user can be searched by firstname and last name.

      My Code

      xhtml

      <h:form id="searchCallCenterAgentForm" style="width:600px;">
       <f:facet name="header">Call Center Agent Search</f:facet>
       <div class="dialog"><h:panelGrid columns="2" rowClasses="prop"
       columnClasses="name,value">
       <h:outputLabel for="firstName">First Name</h:outputLabel>
       <h:inputText id="firstName"
       value="#{callCenterAgentManage.firstName}" style="width:150px"
       required="false">
       <a:support event="onkeyup" actionListener="#{callCenterAgentManage.searchCallCenterAgent}"
       reRender="searchResults" />
       </h:inputText>
       <h:outputLabel for="lastName">Last Name </h:outputLabel>
       <h:inputText id="lastName"
       value="#{callCenterAgentManage.lastName}" style="width:150px"
       required="false">
       <a:support event="onkeyup"
       actionListener="#{callCenterAgentManage.searchCallCenterAgent}"
       reRender="searchResults" />
       </h:inputText>
       </h:panelGrid></div>
       <div class="actionButtons"><a:commandButton value="Search"
       action="#{callCenterAgentManage.searchCallCenterAgent}"
       id="searchCallCenterAgent" reRender="searchResults" /></div>
       </h:form>
       </rich:panel> <rich:panel style="width:600px;">
       <a:outputPanel id="searchResults">
       <div class="section"><h:outputText value="No Agents Found"
       rendered="#{agentDetails != null and agentDetails.rowCount==0}" />
       <h:dataTable id="agentDetails" value="#{agentDetails}" var="details"
       rendered="#{agentDetails.rowCount>0}">
       <h:column>
       <f:facet name="header">User Name</f:facet>
       #{details.strUserName}
       </h:column>
       <h:column>
       <f:facet name="header">First Name</f:facet>
       #{details.person.strFirstName}
       </h:column>
       <h:column>
       <f:facet name="header">Last Name</f:facet>
       #{details.person.strLastName}
       </h:column>
       <h:column>
       <f:facet name="header">Account Status</f:facet>
       #{details.flgAccountStatus}
       </h:column>
       </h:dataTable>
       </a:outputPanel>
       </rich:panel>



      Bean
       private String firstName;
       private String lastName;
       @In
       Account account;
       @In
       FacesMessages facesMessages;
       @PersistenceContext
       private EntityManager em;
       @DataModel
       private List<Account> agentDetails;
      
       private String userName;
      
       public void searchCallCenterAgent() {
       // implement your business logic here
       log.info("callCenterAgentManage.searchCallCenterAgent() action called");
      
       String searchQuery = "select "
       + "a, p "
       + "from Account a, Person p " + "where "
       + "a.flgAccountStatus!='i' " + "and a.flgDeleted='0' "
       + "and a.strUserName!='" + account.getStrUserName() + "' ";
      
       if (!firstName.equals("")) {
       searchQuery += "and lower(p.strFirstName) like #{firstNamePattern} ";
       }
      
       if (!lastName.equals("")) {
       searchQuery += "and lower(p.strLastName) like #{lastNamePattern} ";
       }
      
       searchQuery += " and a.person.ipersonId = p.ipersonId";
       agentDetails = em.createQuery(searchQuery).getResultList();
       log.info("Search query = " + searchQuery);
       log.info("Result count = " + agentDetails.size());
       }
      Getters and setters
      --------------------
      --------------------
      --------------------
      


      When I click search it says
      Error:--
      Exception during request processing:
      Caused by javax.servlet.ServletException with message: "/manage.xhtml: For input string: "strUserName""


      Does anyone have any idea whats going wrong?

      Thanks in advance

      -Vikram