4 Replies Latest reply on Aug 11, 2008 12:09 PM by blabno

    PropertyNotFoundException Target: binding="{helloAction.outputText}": Unreachable, identifier 'helloAction' resolved to null

    blabno Master

      Hi, I have simple facelet attached below. When I click hello button I get exception :


      javax.el.PropertyNotFoundException: /index.xhtml @20,68 binding="#{helloAction.outputText}":
       Target Unreachable, identifier 'helloAction' resolved to null



      However when i remove h:outputText tag everything works fine and in debug I see helloAction in conversation.


      <?xml version='1.0' encoding='UTF-8' ?>
      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:h="http://java.sun.com/jsf/html">
          <head>
              <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
              <title>#{messages.homePageTitle}</title>
          </head>
          <body>
              <div id="content">
                  <h:form>
                      <div><h:messages/></div>
                      <h:panelGrid columns="2">
                          <h:outputText value="#{messages.username}"/>
                          <h:inputText value="#{helloAction.username}"/>
                          <h:commandButton value="hello" action="#{helloAction.sayHello}"/>
                      </h:panelGrid>
                      <h:outputText binding="#{helloAction.outputText}"/>
                  </h:form>
              </div>
          </body>
      </html>



      @Name("helloAction")
      @Stateful
      public class HelloActionBean implements HelloActionLocal {
          private String username;
          @In
          FacesMessages facesMessages;
          private HtmlOutputText outputText = new HtmlOutputText();
          
          @Begin(join=true)
          public void sayHello() {
              getOutputText().setValue("Hello "+username);
              facesMessages.add("Hello "+username);
          }
      
          public String getUsername() {
              return username;
          }
      
          public void setUsername(String username) {
              this.username = username;
          }
      
          public HtmlOutputText getOutputText() {
              return outputText;
          }
      
          public void setOutputText(HtmlOutputText outputText) {
              this.outputText = outputText;
          }
          
          @Remove
          public void remove() {
          }
      }



      Other thing is that if i use


      <h:outputText binding="#{outputText}"/>



      instead of


      <h:outputText binding="#{helloAction.outputText}"/>



      There is no exception but value of h:outputText is not displayed. (it is set in sayHello() method)


      What am I doing wrong ?

        • 1. Re: PropertyNotFoundException Target: binding="{helloAction.outputText}": Unreachable, identifier 'helloAction' resolved to null
          leandro sabin Newbie

          Hi.


          I think the answer to your problem is in the reference documentation:





          7.10. Conversational components and JSF component
          bindings


          Conversational components have one minor limitation: they cannot be used to hold bindings to
          JSF components.


          Because your component is a SFSB the binding does not work. There's a workaround for this in the same section of the manual.


          Hope this helps.

          • 2. Re: PropertyNotFoundException Target: binding="{helloAction.outputText}": Unreachable, identifier 'helloAction' resolved to null
            blabno Master

            Strange cause following works great:


            <rich:tree id="systemTree" 
                          nodeSelectListener="#{categoryManager.processSelection}" 
                          ajaxSubmitSelection="true"
                          switchType="ajax"
                          binding="#{systemTree}" 
                          var="item"
                          adviseNodeSelected="#{categoryManager.adviseNodeSelected}"
                          reRender="systemTree"
                          >
                              <rich:treeNode>#{item.name}</rich:treeNode>
            </rich:tree>



            @Stateful
            @Name("categoryManager")
            public class CategoryManagerBean implements CategoryManagerLocal {
            
                @Out(required = false)
                private UITree systemTree;
                ...
            }

            • 4. Re: PropertyNotFoundException Target: binding="{helloAction.outputText}": Unreachable, identifier 'helloAction' resolved to null
              blabno Master

              What do you mean Pete ? There is binding to conversation scope attribute.
              Btw. That sample above (with richfaces) works great. I'm adding new nodes to UITree and they get rendered. But following sample works strangly.


              @Name("hello")
              @Stateless
              public class HelloActionBean implements HelloActionLocal {
                  private String name;
                  @RequestParameter
                  @Out(required=false)
                  private String paraName;
                  @Out(required=false)
                  private UIOutput text = new HtmlOutputText();
                  @Out(required=false)
                  private HtmlOutputText text2 = new HtmlOutputText();
                  
                  public void sayHello() {
                      text.setValue("Hello "+getName());
                      text2.setValue("Hello "+paraName);
                  }
              
                  public String getName() {
                      return name;
                  }
              
                  public void setName(String name) {
                      this.name = name;
                  }
              }



              <h:form>
                  #{paraName}<br/>
                  text : <h:outputText binding="#{text}"/><br/>
                  text2 : <h:outputText binding="#{text2}"/><br/>
                  <h:inputText value="#{hello.name}"/>
                  <h:commandButton action="#{hello.sayHello}"/>
              </h:form>



              When I enter in my browser following URL index.seam?paraName=jasio I get :


              jasio
              text :Hello null
              text2 :Hello jasio



              When I submit form with input text filled with adam I get :


              text :Hello null
              text2 :Hello jasio



              And then when again enter in browser index.seam?paraName=jasio3 I get :


              jasio3
              text :Hello adam
              text2 :Hello jasio3



              Why input submitted in form is not printed instantly ?


              BTW. I've seen example where both binding and value attributes were specified. Doesn't binding include value ?