3 Replies Latest reply on Mar 18, 2010 7:26 AM by nimo stephan

    contextMenu menuItem value to bean

    nimo stephan Master

      I view a contextMenu via rich:componentControl triggered by "onRowClick".

       

      <h:form  id="formTable">

      <rich:extendedDataTable  value="#{myBean.users}" var="u" height="100px">

       

      <rich:column>

        ..

      </rich:column>

      ..


      <rich:componentControl event="onRowClick" for="formMenu:contextMenu" operation="show">
                      <f:param
      name="selectedName" value="#{u.username}" />
      </rich:componentControl>

       

      </rich:extendedDataTable>

      </h:form>


      <h:form  id="formMenu">

      <rich:contextMenu  attached="false" id="contextMenu"  submitMode="ajax" hideDelay="0"  showDelay="0">

      <!-- using selectedName in a4j:actionparam works   -->   

      <rich:menuItem value="Details:  {selectedName}"  reRender="viewUser" limitToList="true"  ajaxSingle="true">

                  <a4j:actionparam name="assingValue" assignTo="#{selectedUser.username}" value="{selectedName}"/>

      </rich:menuItem>

       

      <!-- using selectedName in a action as a parameter does NOT work , selectedName is always NULL  -->

      <rich:menuItem value="Details:  {selectedName}"   action="#{myBean.viewUser(selectedName)}" reRender="viewUser" limitToList="true"  ajaxSingle="true"/>
      ..

      </rich:contextMenu>

      </h:form>

       

      Why can I not use the param "selectedName" in "myBean.viewUser(selectedName)" ?

        • 1. Re: contextMenu menuItem value to bean
          Nick Belaevski Master

          Hi Nimo,

           

          Probably it works. You should enclose all parameters into braces: {...}, but you didn't do this for 'selectedName'.

          • 2. Re: contextMenu menuItem value to bean
            nimo stephan Master

            Hello,

             

            unfortunately this

             

            <rich:menuItem value="Details: {selectedName}" action="#{myBean.viewUser({selectedName})}" limitToList="true" ajaxSingle="true"/>

             

            leads to the following error:

             

            Caused by: org.jboss.el.parser.ParseException: Encountered "{" at line 1, column 38.
            Was expecting one of:
                <INTEGER_LITERAL> ...
                <FLOATING_POINT_LITERAL> ...
                <STRING_LITERAL> ...
                "true" ...
                "false" ...
                "null" ...
                "(" ...
                ")" ...
                "!" ...
                "not" ...
                "empty" ...
                "-" ...
                <IDENTIFIER> ...
                <NAMESPACE> ...
               
                at org.jboss.el.parser.ELParser.generateParseException(ELParser.java:2078)
                at org.jboss.el.parser.ELParser.jj_consume_token(ELParser.java:1958)
                at org.jboss.el.parser.ELParser.MethodSuffix(ELParser.java:1160)
                at org.jboss.el.parser.ELParser.DotSuffix(ELParser.java:1048)
                at org.jboss.el.parser.ELParser.Value(ELParser.java:983)
                at org.jboss.el.parser.ELParser.Unary(ELParser.java:951)
                at org.jboss.el.parser.ELParser.Multiplication(ELParser.java:714)
                at org.jboss.el.parser.ELParser.Math(ELParser.java:634)
                at org.jboss.el.parser.ELParser.Compare(ELParser.java:446)
                at org.jboss.el.parser.ELParser.Equality(ELParser.java:340)
                at org.jboss.el.parser.ELParser.And(ELParser.java:284)
                at org.jboss.el.parser.ELParser.Or(ELParser.java:228)
                at org.jboss.el.parser.ELParser.Choice(ELParser.java:182)
                at org.jboss.el.parser.ELParser.Expression(ELParser.java:174)
                at org.jboss.el.parser.ELParser.DeferredExpression(ELParser.java:112)
                at org.jboss.el.parser.ELParser.CompositeExpression(ELParser.java:40)
                at org.jboss.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:98)
                ... 125 more
            11:46:52,198 WARN  [ExceptionFilter] running exception handlers
            11:46:52,198 INFO  [STDOUT] AfterPhase: RENDER_RESPONSE 6
            11:46:52,229 INFO  [STDOUT] BeforePhase: RESTORE_VIEW 1
            11:46:52,229 INFO  [STDOUT] AfterPhase: RESTORE_VIEW


            • 3. Re: contextMenu menuItem value to bean
              nimo stephan Master

              I have also tried it by using ui:param instead of f:param.

               

              I have to use f:param to access the attribute via {selectedName} and cannot access it via #{selectedName}.

               

              So, I guess, the only solution is to provide a actionparam.