5 Replies Latest reply on Sep 2, 2009 8:46 PM by nbelaevski

    Identifier is nulll, sometimes, when used with s:button

    pdpantages

      Hello Forum,

      I am using:

      jboss_version=5.0.1.GA
      seam_version=2.1.2.GA
      richfaces_version=3.3.1.GA

      I have an s:button I want to use in a facelet included with a ui:include statement.

      I had prototyped some code in a single (big) file and everything is working as expected.

      I moved some of the code to an includable file (facelet), which I pull in with ui:include, and assign a few parameters.

      No changes to any of the server side beans (java code) were made when this was done.

      What I find is that my s:button no longer works. The tablebean (see below) is NULL in the action parameter. But it is NOT NULL when used in the value or the poller (see below).

      My question is: why? I don't get how an expression can evaluate to null when the same expession two lines earlier was OK....

      I tried switching the s:button for s:link, a4j:commandButton a4j:commandLink; no change in behaviour.

      Does anyone have any ideas ? Anything will be appreciated......

      The facelet is included like so. The "endPointPm" assigned to param tablebean is an SFSB in seam conversation scope.

      <a4j:repeat value="#{pmd.pmParms}" var="pmp" rowKeyVar="rkv1">
       <ui:include src="/view/utils/pm/pmlive.xhtml">
       <ui:param name="panelId" value="PL_#{rkv0}_#{rkv1}"/>
       <ui:param name="rkprefix" value="L_"/>
       <ui:param name="tablebean" value="#{endPointPm}"/>
       <ui:param name="pmp" value="#{pmp}"/>
       <ui:param name="rkv0" value="#{rkv0}"/>
       <ui:param name="rkv1" value="#{rkv1}"/>
       <ui:param name="interval" value="4000"/>
       </ui:include>
      </a4j:repeat>
      
      

      Inside the included file, I use an s:button like so:
      <s:button value="Full #{tablebean.profile}"
       title="Full"
       action="#{tablebean.showFsLive}">
       <f:param name="id" value="#{pmp.id}"/>
       <a4j:support event="onclick"
       reRender="mainPanel,livePanel,histPanel,singlePanel"
       eventsQueue="ajaxQueue"/>
      </s:button>
      

      Note the #{tablebean.profile} in the value. I just did this to verify that the tablebean is not null (the complaint in the exception).

      When I press the button I get this:

      javax.el.PropertyNotFoundException: Target Unreachable, identifier 'tablebean' resolved to null
       at org.jboss.el.parser.AstValue.getTarget(AstValue.java:38)
       at org.jboss.el.parser.AstValue.invoke(AstValue.java:95)
       at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
       at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:175)
       at org.jboss.seam.navigation.Pages.callAction(Pages.java:692)
       at org.jboss.seam.navigation.Pages.preRender(Pages.java:330)
       at org.jboss.seam.jsf.SeamPhaseListener.preRenderPage(SeamPhaseListener.java:561)
       at org.jboss.seam.jsf.SeamPhaseListener.beforeRenderResponse(SeamPhaseListener.java:472)
       at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:148)
       at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:118)
       at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
       at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
       at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      


      This poller references tablebean w/o problems:

      
      <a4j:region renderRegionOnly="false">
       <a4j:poll
       interval="#{interval}"
       enabled="true"
       status="pollingStatus"
       data="#{tablebean.liveNewvalJSON}"
       oncomplete="#{rkprefix}#{rkv0}_#{rkv1}_UpdateJSON(data)"
       eventsQueue="ajaxQueue">
       <f:param name="id" value="#{pmp.id}"/>
       </a4j:poll>
      </a4j:region>
      
      


        • 1. Re: Identifier is nulll, sometimes, when used with s:button
          ilya_shaikovsky

          As far as I remember - you can't define actions using parameters like this in facelets. And this is not related to richfaces. I suggest you to check facelets mailing lists.

          • 2. Re: Identifier is nulll, sometimes, when used with s:button
            pdpantages

            Thank you for the reply, Ilya.

            I don't think this is prohibited in facelets. (I am not certain that it is a richfaces problem either... ).

            I have used this technique successfully in the past (in that case w/o the a4j:repeat), including the use of action methods. In that case I used a4j:commandLink.

            I am going to give a4j:commandLink another look; my first try I just switched the s:button for a4j;commandLink, but did not remove the a4j:support. I know that this isn't quite right, but I didn't think it could cause null values

            I will take a look at the facelets forum(s) also....

            PdP

            • 3. Re: Identifier is nulll, sometimes, when used with s:button
              nbelaevski

              Hi,

              Using a4j:commandLink together with a4j:support can cause concurrent request issues - maybe that's the reason why conversation-scoped bean resolves to null?

              • 4. Re: Identifier is nulll, sometimes, when used with s:button
                pdpantages

                Hello Nick, thank you for the input.

                Anything is possible.... However, my beans are @Syncrhonized and I did not see any exceptions in the Jboss log that hinted at "concurrent modification" or anything like that.

                In any case, the commandButton (below) is now working.

                I can manage with a4j:commandButton, but does anyone have any idea why s:button+a4j:support does not work? I would like to get an understanding of
                what scenarios to avoid in the future.

                S:link behaves the same way as s:button.

                This works:

                <a4j:commandButton
                 value="xyz"
                 rendered="#{not pmp.integrated}"
                 title="Integrate the values in this chart."
                 action="#{tablebean.integrateLive}"
                 data="#{tablebean.liveNewvalJSON}"
                 oncomplete="#{rkprefix}#{rkv0}_#{rkv1}_UpdateJSON(data)"
                 eventsQueue="ajaxQueue">
                 <f:param name="id" value="#{pmp.id}"/>
                </a4j:commandButton>
                



                • 5. Re: Identifier is nulll, sometimes, when used with s:button
                  nbelaevski

                  Hello,

                  Yes, my guess was wrong and that's not a concurrent modification problem. Here is what I've missed in the posted log:

                  at org.jboss.seam.navigation.Pages.callAction(Pages.java:692)
                   at org.jboss.seam.navigation.Pages.preRender(Pages.java:330)
                   at org.jboss.seam.jsf.SeamPhaseListener.preRenderPage(SeamPhaseListener.java:561)

                  as this happens when calling page action, I guess it's fair that it can't resolve "tablebean". Let's take a look at code related to Expressions$2 class
                  public <T> MethodExpression<T> createMethodExpression(final String expression, final Class<T> type, final Class... argTypes)
                   {
                   return new MethodExpression<T>()
                   {
                   private javax.el.MethodExpression facesMethodExpression;
                   private javax.el.MethodExpression seamMethodExpression;
                  
                   public javax.el.MethodExpression toUnifiedMethodExpression()
                   {
                   if ( isFacesContextActive() )
                   {
                   if (seamMethodExpression==null)
                   {
                   seamMethodExpression = createExpression();
                   }
                   return seamMethodExpression;
                   }
                   else
                   {
                   if (facesMethodExpression==null)
                   {
                   facesMethodExpression = createExpression();
                   }
                   return facesMethodExpression;
                   }
                   }
                  
                   private javax.el.MethodExpression createExpression()
                   {
                   return getExpressionFactory().createMethodExpression( getELContext(), expression, type, argTypes );
                   }
                  
                   public T invoke(Object... args)
                   {
                   return (T) toUnifiedMethodExpression().invoke( getELContext(), args );
                   }
                  
                   public String getExpressionString()
                   {
                   return expression;
                   }
                  
                   };
                   }

                  here we can see that there's no context to resolve "tablebean" in (some kind of javax.el.VariableMapper is such context - see Facelets templating-related code for more info). So createExpression() creates method expression successfully, but then it just can't be evaluated.

                  Hope this explains the problem well, please let me know if I missed something.