3 Replies Latest reply on Nov 3, 2009 6:39 PM by chrismueller

    Target Unreachable, identifier 'donorHome' resolved to null

      I used the JBoss Tools wizard to reverse engineer a gui from a table (File - New - Seam Generate Entities) which I am pretty sure is just using the generate-entities seam script.


      This worked great when I made a table called person with a lastname and firstname column.


      It made the gui and all that...


      I then tried to manually make my own called donor. I copied all of the person code that I could find and changed it to donor.


      It works... but when I go to the person page it says


      Target Unreachable, identifier 'donorHome' resolved to null


      I figure that it is using the @Name annotation to get a reference to the 'donorHome' object.  Do I need to do anything else for the JSF to be able to reference the 'donorHome' class?


      So, here is my code:


      DonorEdit.xhtml:


      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:s="http://jboss.com/products/seam/taglib"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:a="http://richfaces.org/a4j"
                      xmlns:rich="http://richfaces.org/rich"
                      template="layout/template.xhtml">
                             
      <ui:define name="body">
          
          <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>
      
          <h:form id="donor" styleClass="edit">
          
              <rich:panel>
                  <f:facet name="header">#{donorHome.managed ? 'Edit' : 'Add'} Donor</f:facet>
      
                  <s:decorate id="lastnameDecoration" template="layout/edit.xhtml">
                      <ui:define name="label">lastname</ui:define>
                      <h:inputTextarea id="lastname"
                                     cols="80"
                                     rows="3"
                                 disabled="#{donorHome.managed}"
                                 required="true"
                                    value="#{donorHome.instance.id.lastname}"/>
                  </s:decorate>
      
                  <s:decorate id="firstnameDecoration" template="layout/edit.xhtml">
                      <ui:define name="label">firstname</ui:define>
                      <h:inputTextarea id="firstname"
                                     cols="80"
                                     rows="3"
                                 disabled="#{donorHome.managed}"
                                 required="true"
                                    value="#{donorHome.instance.id.firstname}"/>
                  </s:decorate>
              
                  <div style="clear:both">
                      <span class="required">*</span> 
                      required fields
                  </div>
                  
              </rich:panel>
                      
              <div class="actionButtons">
      
                  <h:commandButton id="save" 
                                value="Save" 
                               action="#{donorHome.persist}"
                             disabled="#{!donorHome.wired}"
                             rendered="#{!donorHome.managed}"/>  
                                                 
                  <h:commandButton id="update" 
                                value="Save" 
                               action="#{donorHome.update}"
                             rendered="#{donorHome.managed}"/>
                                               
                  <h:commandButton id="delete" 
                                value="Delete" 
                               action="#{donorHome.remove}"
                             rendered="#{donorHome.managed}"/>
                          
                  <s:button id="done" 
                         value="Done"
                   propagation="end"
                          view="/Donor.xhtml"
                      rendered="#{donorHome.managed}"/>
                      
                  <s:button id="cancel" 
                         value="Cancel"
                   propagation="end"
                          view="/#{empty donorFrom ? 'DonorList' : donorFrom}.xhtml"
                      rendered="#{!donorHome.managed}"/>
      
              </div>
          </h:form>
      
      </ui:define>
      
      </ui:composition>




      DonorHome.java:


      package org.donatetoscience.DonateToScience.session;
      
      import org.donatetoscience.DonateToScience.entity.*;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.framework.EntityHome;
      import org.jboss.seam.util.Strings;
      
      @Name("donorHome")
      public class DonorHome extends EntityHome<Donor> {
      
           public void setDonorId(DonorId id) {
                setId(id);
           }
      
           public DonorId getDonorId() {
                return (DonorId) getId();
           }
      
           public DonorHome() {
                setDonorId(new DonorId());
           }
      
           @Override
           public boolean isIdDefined() {
                if (Strings.isEmpty(getDonorId().getLastname()))
                     return false;
                if (Strings.isEmpty(getDonorId().getFirstname()))
                     return false;
                return true;
           }
      
           @Override
           protected Donor createInstance() {
                Donor donor = new Donor();
                donor.setId(new DonorId());
                return donor;
           }
      
           public void wire() {
           }
      
           public boolean isWired() {
                return true;
           }
      
           public Donor getDefinedInstance() {
                return isIdDefined() ? getInstance() : null;
           }
      
      }