13 Replies Latest reply on Mar 25, 2011 8:20 AM by jobmathew

    Richface Context Menu problem

    jobmathew

      HI,

       

      I am trying create a context menu for a data table,

       

      The problem lies when i pass the control to the context menu i pass try to pass two variables but those variables are been passed with null values.

       

      couldnt figure out why.

       

      please help.....

       

      there is my code

       

      <rich:contextMenu attached="false" id="ContextMenu" submitMode="ajax">

                  <rich:menuItem value="Edit Record" ajaxSingle="true"

                       oncomplete="#{rich:component('modeEditPanel')}.show()"

                      actionListener="#{manageUserBean.fetchCurrentRow}" >

                      <a4j:actionparam name="id" value="#{selectedRow}"  assignTo="#{TableBean.selectedRow}"/>

                      <a4j:actionparam name="row" value="#{currentRow}" assignTo="#{TableBean.row}" />

                  </rich:menuItem>

      </rich:contextMenu>

       

              <a4j:region>    

                         <rich:dataTable width="100%" onRowMouseOver="this.style.backgroundColor='#{a4jSkin.tabBackgroundColor}'"  

                                    onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"

                                     value="#{manageTableBean.modeTable}"  var="Step" rows="20" rowKeyVar="Row"

                                  id="Table" onRowContextMenu=" Row=this;

                                  #{rich:component('ContextMenu')}.show(event,{selectedRow:'#{Step}', currentRow:'#{Row}'});

                                  return false;">

        • 1. Richface Context Menu problem
          nbelaevski

          Hi,

           

          For client-side templates parameters you should use {selectedRow} expression, not EL-expression.

          • 2. Re: Richface Context Menu problem
            jobmathew

            I changed my code accordingly but still am having NP  exception

             

            my modified code is

             

            <rich:contextMenu attached="false" id="ContextMenu" submitMode="ajax">

                        <rich:menuItem value="Edit Record" ajaxSingle="true"

                             oncomplete="#{rich:component('modeEditPanel')}.show()"

                            actionListener="#{manageUserBean.fetchCurrentRow}" >               

                            <a4j:actionparam name="row" value="{selectedRowNumber}"  />

                            <a4j:actionparam name="modeTableRowIndex" value="{modeTableIndex}"  />

                        </rich:menuItem>

            </rich:contextMenu>

             

                    <a4j:region>    

                               <rich:dataTable width="100%" onRowMouseOver="this.style.backgroundColor='#{a4jSkin.tabBackgroundColor}'"  

                                          onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"

                                           value="#{manageTableBean.modeTable}"  var="Step" rows="20" rowKeyVar="Row"

                                        id="Table" onRowContextMenu=" Row=this;

                                        #{rich:component('modeContextMenu')}.show(event,{selectedRowNumber:'#{Row}' ,modeTableIndex:'#{Step.id}'});

                                        return false;">

             

            and on debuging i see in the actionevent binding

             

            [oncomplete=/Pages/ManageTable.xhtml @14,126 oncomplete="#{rich:component('modeEditPanel')}.show()": ValueExpression[#{rich:component('modeEditPanel')}.show()], null]

             

            Exception

             

            SCHWERWIEGEND: Received 'java.lang.NullPointerException' when invoking action listener '#{manageUserBean.fetchCurrentRow}' for component 'j_id42'

            24.03.2011 16:13:47 javax.faces.event.MethodExpressionActionListener processAction

            SCHWERWIEGEND: java.lang.NullPointerException

            • 3. Re: Richface Context Menu problem
              ilya_shaikovsky

              add noEscape="true" to parameters.

              • 4. Re: Richface Context Menu problem
                jobmathew

                on which node

                 

                actionparam or onRowContextMenu

                • 5. Re: Richface Context Menu problem
                  ilya_shaikovsky

                  sorry. to actionparam tag.

                  • 6. Re: Richface Context Menu problem
                    jobmathew

                    NO probs....

                     

                     

                    But still have the same problem

                     

                      <a4j:actionparam name="id" value="{userID}" noEscape="true" assignTo="#{TableBean.projectId}"/>

                                    <a4j:actionparam name="row" value="{currentRow}" noEscape="true" assignTo="#{TableBean.row}" />

                     

                     

                    SCHWERWIEGEND: Received 'java.lang.NullPointerException' when invoking action listener '#{TableBean.fetchCurrentRow}' for component 'j_id41'

                    25.03.2011 12:14:53 javax.faces.event.MethodExpressionActionListener processAction

                    SCHWERWIEGEND: java.lang.NullPointerException

                        at net.rim.amalia.view.pages.ManageActionTableBean.fetchCurrentRow(TableBean.java:121)

                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                    • 7. Re: Richface Context Menu problem
                      jobmathew

                      What is the role of  name in actionparm?

                       

                      should it be the same name of like the private filed in the bean class ?

                      • 8. Re: Richface Context Menu problem
                        ilya_shaikovsky

                        no name should be used   if you want to get the param from request params map..

                         

                        B.t.w. #{TableBean.row}.. shouldn't it be #{tableBean.row}?

                        • 9. Re: Richface Context Menu problem
                          jobmathew

                          that was a typo.

                           

                          in my code it was correct

                          it was  #{tableBean.row}

                          • 10. Re: Richface Context Menu problem
                            jobmathew

                            more question

                             

                               <a4j:actionparam name="row" value="{currentRow}" noEscape="true" assignTo="#{tableBean.row}" />

                             

                            tableBean.row should point to getter or setter of the  bean property row ?

                             

                            tableBean.projectId is pointing to setter and tableBean.row is pointing to getter of the private fields..

                             

                            i dont know why...

                             

                            does any one have an answer for this !!!!

                            • 11. Re: Richface Context Menu problem
                              jobmathew

                              ok i have figured out this rearding getter and setter.

                               

                              the order of getter and setter in the bean class.

                               

                              which one comes first. this is been pointed to

                              • 12. Re: Richface Context Menu problem
                                ilya_shaikovsky

                                Doh.. finally I think get the problem

                                 

                                move actionListener="#{manageUserBean.fetchCurrentRow}"  to the last param tag also. thats known JSF prblem that nested actionListeners are called after ones defined at tag. so the parameters getting set *after* your listener call.

                                • 13. Re: Richface Context Menu problem
                                  jobmathew

                                  Thank you so much..

                                   

                                   

                                  Have update the code like this

                                   

                                  <rich:menuItem value="Edit Record" ajaxSingle="true"

                                                   oncomplete="#{rich:component('editPanel')}.show()"

                                                  actionListener="#{manageUserBean.fetchCurrentRow}" >

                                                  <a4j:actionparam name="id" value="{userID}"  assignTo="#{tableBean.projectId}"/>

                                                  <a4j:actionparam name="row" value="{currentRow}" assignTo="#{tableBean.row}" />

                                              </rich:menuItem>

                                   

                                  and its working without problem.

                                   

                                  many many many thanks.......  spend around 3 days on this