2 Replies Latest reply on Nov 14, 2007 3:19 PM by whafrog

    Target Unreachable with two entity instances?

    whafrog

      Hi, I have a page that contains two forms, one for search and one for save/update. If I use a single entity instance for both forms, everything works well enough, but the search field is sync'd with the save/update field. If I try to have two entity instances (one for the search form, one for the save/update form) I get a:

      javax.el.PropertyNotFoundException: /lender.xhtml @22,71 value="#{searchLender.lenderCode}": Target Unreachable, identifier 'searchLender' resolved to null

      LenderManagerAction:

      @In
       private Lender searchLender;
      
       @In
       private Lender lender;
      
       @In
       private FacesMessages facesMessages;
      
       public String search()
       {
       Query query = entityManager.createNamedQuery(Lender.class.getSimpleName() + ".findByCode");
       query.setParameter("lenderCode", searchLender.getLenderCode());
       try {
       lender = (Lender)query.getSingleResult();
       } catch (NoResultException e) {
       logger.info(e.getMessage());
       facesMessages.add("Lender not found for code: " + searchLender.getLenderCode());
       return null;
       }
       return PAGE_LENDER;
       }
      


      lender.xhtml:

      <h:panelGrid columns="2" rowClasses="prop" columnClasses="name,value">
       <h:outputLabel for="searchLender">Lender Code</h:outputLabel>
       <h:inputText value="#{searchLender.lenderCode}" size="6"/>
       </h:panelGrid>
       <div class="actionButtons">
       <h:commandButton type="submit" value="Search" action="#{lenderManager.search}"/>
       </div>
      


      All I have to do to make this work is remove "searchLender" from the session bean, and point the search form to the common "lender" entity. Is there a problem with having two instances of the same entity type?

      Thanks,

      Jon