2 Replies Latest reply on Mar 21, 2006 7:18 AM by newlukai

    Target Unreachable, identifier 'currentTestaction' resolved

      Hi folks,

      I've a web application which uses Seam 1.0 beta 2 on a JBoss AS 4.0.4 RC1 with Facelets (from the booking demo) and myFaces 1.1.1.
      I've a session scoped component with a member: currentTestaction (@In(required=false) @Out(required=false). The member's attributes are displayed in a form. Some of them are editable (inputText) and are simple Strings, so I didn't append a converter. If the user hits the "save" button his changes should be saved.
      After hitting the save button, the 'Restore view' and the 'Apply request values' phases do their job. After these phases there is a viewRoot, which has all the entered information. The next phase, 'Process validations', tries to validate all the entered information. Because I didn't append a converter myFaces tries to determine the type (ValueBinding.getType()). But then there is a PropertyNotFoundException thrown: "Target Unreachable, identifier 'currentTestaction' resolved to null".

      Has anybody an idea, why 'currentTestaction' cannot be resolved?

      Here's the code of the component:

      @Stateful
      @Scope(ScopeType.SESSION)
      @LoggedIn
      @Name("testactionDeveloper")
      @Interceptors(SeamInterceptor.class)
      public class TestactionDeveloperAction implements TestactionDeveloper, Serializable {
       @PersistenceContext(unitName = "aresDatabase")
       private EntityManager em;
      
       @In @Valid
       private User user;
      
       @DataModel(scope=ScopeType.PAGE)
       private List<Testaction> testactions;
       @DataModelSelectionIndex
       private int testactionIndex;
       @DataModelSelection
       private Testaction testaction;
      
       @In(required=false)
       @Out(required=false)
       private Testaction currentTestaction;
      
       private List<Testaction> currentTestactions;
       private int currentTestactionIndex;
      
       @In(required=false)
       private Release selectedRelease;
      
       @In private FacesContext facesContext;
       @In private Context sessionContext;
      
      
       @Factory("testactions")
       public void initTestactions() {
       if(selectedRelease != null) {
       testactions = em.createQuery(
       "from Testaction where TACT_DEV_USR_ID=:dev and TACT_REL_ID=:rel and (TACT_REV_ID is null or TACT_REV_ID=9) order by TACT_ID asc"
       ).setParameter("dev", user.getID()).setParameter("rel", selectedRelease.getID()).getResultList();
       } else {
       testactions = em.createQuery(
       "from Testaction where TACT_DEV_USR_ID=:dev and (TACT_REV_ID is null or TACT_REV_ID=9) order by TACT_ID asc"
       ).setParameter("dev", user.getID()).getResultList();
       }
       }
      
       public String select() {
       currentTestaction = testaction;
       currentTestactions = testactions;
       currentTestactionIndex = testactionIndex;
       return "selected";
       }
      
       public String saveTestaction() {
       System.out.println("saveTestaction()");
       return "backToList";
       }
      
       public String saveTestactionAndNext() {
       System.out.println("saveTestactionAndNext()");
       return nextTestaction();
       }
      
       public String nextTestaction() {
       if(shiftTestaction(1)) {
       return "browse";
       }
       return "backToList";
       }
      
       public String prevTestaction() {
       if(shiftTestaction(-1)) {
       return "browse";
       }
       return "backToList";
       }
      
       public int getTestactionIndexHR() {
       return currentTestactionIndex + 1;
       }
      
       public int getTestactionsSize() {
       if(currentTestactions == null ) {
       return 0;
       }
       return currentTestactions.size();
       }
      
       public String getDeveloperReleaseHR() {
       if(currentTestaction == null ) {
       return "devrelease";
       }
       List<Release> release = em.createQuery(
       "from Release where REL_ID=:relID order by REL_ID asc"
       ).setParameter("relID", currentTestaction.getDevRelID()).getResultList();
       String result = "release not found";
       if(release.size() > 0) {
       result = release.get(0).getRelToken();
       }
       return result;
       }
      
       @Remove @Destroy
       public void destroy() {
       }
      
       private boolean shiftTestaction(int distance) {
       if(currentTestactions.size() == 0) {
       return false;
       }
       currentTestactionIndex += distance;
       while(currentTestactionIndex >= currentTestactions.size()) {
       currentTestactionIndex -= currentTestactions.size();
       }
       while(currentTestactionIndex < 0) {
       currentTestactionIndex += currentTestactions.size();
       }
       currentTestaction = currentTestactions.get(currentTestactionIndex);
       return true;
       }
      }


      and the page:
      <ui:define name="content">
       <h:form>
       <div class="errors"><h:messages globalOnly="true" /></div>
       <div class="buttonLine">
       <h:commandButton action="#{testactionDeveloper.saveTestaction}" value="save" />
       <!-- <h:commandButton action="#{testactionDeveloper.saveTestaction}" image="img/showTestaction.save.gif" styleClass="graphical" /> -->
       <h:commandButton action="#{testactionDeveloper.saveTestactionAndNext}" image="img/showTestaction.saveAndNext.gif" styleClass="graphical" />
      
       <h:commandButton action="#{testactionDeveloper.prevTestaction}" image="img/showTestaction.prev.gif" styleClass="graphical" />
       <h:outputText value="#{testactionDeveloper.testactionIndexHR} | #{testactionDeveloper.testactionsSize}" styleClass="indexAndSize" />
       <h:commandButton action="#{testactionDeveloper.nextTestaction}" image="img/showTestaction.next.gif" styleClass="graphical" style="margin-left: 0px; margin-right: 15px;" />
       </div>
      
       <table cellpadding="0" cellspacing="0" border="0">
       <tr>
       <th><h:outputText value="#{ares_messages.label_testaction_ID}" /></th>
       <th><h:outputText value="#{ares_messages.label_testaction_TDate}" /></th>
       <!-- <th><h:outputText value="#{ares_messages.label_testaction_TCaseID}" /></th> -->
       <th><h:outputText value="#{ares_messages.label_testaction_TesterUsrID}" /></th>
       <th><h:outputText value="#{ares_messages.label_testaction_EnvID}" /></th>
       <th><h:outputText value="#{ares_messages.label_testaction_SevID}" /></th>
       <th><h:outputText value="#{ares_messages.label_testaction_EditorUsrID}" /></th>
       <!-- <th><h:outputText value="#{ares_messages.label_testaction_DevUsrID}" /></th> -->
       <!-- <th><h:outputText value="#{ares_messages.label_testaction_RevID}" /></th> -->
       <th><h:outputText value="#{ares_messages.label_testaction_ChnglistID}" /></th>
       <th><h:outputText value="#{ares_messages.label_testaction_ValidatorUsrID}" /></th>
       <th> </th>
       </tr>
       <tr>
       <td><h:outputText value="#{currentTestaction.ID}" /></td>
       <td><h:outputText value="#{currentTestaction.TDate}" /></td>
       <!-- <td>
       <h:selectOneMenu value="#{currentTestaction.TCaseID}">
       <f:selectItems value="#{showTestactionForDevelopers.testcases}" />
       <f:convertNumber />
       </h:selectOneMenu>
       </td> -->
       <td><h:outputText value="#{currentTestaction.testerUsrID}" /></td>
       <td><h:outputText value="#{currentTestaction.envID}" /></td>
       <td><h:outputText value="#{currentTestaction.sevID}" /></td>
       <td><h:outputText value="#{currentTestaction.editorUsrID}" /></td>
       <!-- <td>
       <h:selectOneMenu value="#{currentTestaction.devUsrID}">
       <f:selectItems value="#{showTestactionForDevelopers.developers}" />
       <f:convertNumber />
       </h:selectOneMenu>
       </td> -->
       <!-- <td>
       <h:selectOneMenu value="#{currentTestaction.revID}">
       <f:selectItems value="#{showTestactionForDevelopers.revisions}" />
       <f:convertNumber />
       </h:selectOneMenu>
       </td> -->
       <td><h:inputText value="#{currentTestaction.chnglistID}" /></td>
       <td><h:outputText value="#{currentTestaction.validatorUsrID}" /></td>
      
       <td> </td>
       </tr>
       </table>
       <table cellpadding="0" cellspacing="0" border="0">
       <tr>
       <th><h:outputText value="#{ares_messages.label_testaction_CompID}" /></th>
       <th><h:outputText value="#{ares_messages.label_testaction_TCaseToken}" /></th>
       <th><h:outputText value="#{ares_messages.label_testaction_Cost}" /></th>
       </tr>
       <tr>
       <td><h:outputText value="#{currentTestaction.compID}" /></td>
       <td><h:outputText value="#{currentTestaction.TCaseToken}" /></td>
       <td><h:inputText value="#{currentTestaction.cost}"><f:convertNumber /></h:inputText></td>
       </tr>
       </table>
       <table cellpadding="0" cellspacing="0" border="0">
       <tr>
       <th><h:outputText value="#{ares_messages.label_testaction_TestBNrID}" /></th>
       <th><h:outputText value="#{ares_messages.label_testaction_DevRelID}" /></th>
       <th><h:outputText value="#{ares_messages.label_testaction_DevBNrID}" /></th>
       <th><h:outputText value="#{ares_messages.label_testaction_DefCID}" /></th>
       <th> </th>
       </tr>
       <tr>
       <td><h:outputText value="#{currentTestaction.testBNrID}" /></td>
       <td><h:outputText value="#{testactionDeveloper.developerReleaseHR} (#{currentTestaction.devRelID})" /></td>
       <td><h:outputText value="#{currentTestaction.devBNrID}" /></td>
       <td><h:outputText value="#{currentTestaction.defCID}" /></td>
       <td> </td>
       </tr>
       </table>
       </h:form>
      </ui:define>