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

    Target Unreachable with two entity instances?

    whafrog Newbie

      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


       private Lender searchLender;
       private Lender lender;
       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) {
       facesMessages.add("Lender not found for code: " + searchLender.getLenderCode());
       return null;
       return PAGE_LENDER;


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

      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?