6 Replies Latest reply on Feb 23, 2009 9:08 PM by nbelaevski

    support action within rich:componentControl

    nimo22

      I want to do something like:

      I have this in my datatable:

      <h:form>
      <rich:componentControl event="onclick" for="menu" operation="show">
      <a4j:support event="onclick" action="#{myBean.do(_a)}"/>
      </rich:componentControl>
      </h:form>
      


      but the action is not invoked, how can I solve that?

        • 1. Re: support action within rich:componentControl
          nbelaevski

          Hi,

          rich:componentControl doesn't have "onclick" attribute, so a4j:support won't work there. Try to use a4j:jsFunction instead.

          • 2. Re: support action within rich:componentControl
            nimo22

            hello,

            I have tried it with a4j:jsFunction, but I do anything wrong:

            I have a datatable with a context-menu (this works):

            
            // my DataTable
            <rich:extendedDataTable value="#{myBean.myList}" var="myRow">
            
            <rich:column>
            ...
            </rich:column>
            
            <rich:componentControl event="onRowClick" for="myContextMenu" operation="show" attachTiming="onload">
            <f:param name="name" value="#{myRow.name}"/>
            </rich:componentControl>
            
            </rich:extendedDataTable>
            
            // my ContextMenu
            
            <rich:contextMenu attached="false" id="myContextMenu" submitMode="ajax" hideDelay="0" showDelay="0">
            <rich:menuItem value="{name}" ajaxSingle="true">
            
            


            When I click a row, the context-menu appears.

            Additionally, I want this:
            When I click a row, a server-side action should be invoked and after that action, the context-menu should appear.

            So I added this:

            <a4j:jsFunction name="invokeJs" action="#{myBean.selectedRow(myRow)}"/>
            
            // add onRowClick-Property and bind it to a action
            <rich:extendedDataTable onRowClick="invokeJs(myRow)" value="#{myBean.myList}" var="myRow">


            but it does not work.

            I only want to do a action when I click a row, and then after the action, the context-menu should appear. Do you know, what is wrong?

            • 3. Re: support action within rich:componentControl
              nbelaevski

              Hello,

              "myRow" is a server-side expression, it's illegal to pass this to the client-side function. You can use this:

              <rich:extendedDataTable id="dtrChfImediataList" var="item"
               value="#{forum5Bean.data}">
               <rich:column>
               #{item.value}
               </rich:column>
              
               <a4j:support event="onRowClick" oncomplete="#{rich:component('menu')}.show(event, {name: '#{item.value}'})" />
               </rich:extendedDataTable>
              
               <rich:contextMenu attached="false" id="menu">
               <rich:menuItem value="{name}" />
               </rich:contextMenu>


              P.S. In pure JSF method expressions does not support passing arguments. You need Seam for that.

              • 4. Re: support action within rich:componentControl
                nimo22

                hello nbelaevski,

                thank you very very much!! Now -with your help - it works fine :-)

                (Besides, I use seam and could use the WebRemote,
                however show(event, context)-function is sufficient.)

                thank you!

                • 5. Re: support action within rich:componentControl
                  nimo22

                  By the way, the rich:contextMenu has the onexpand-attribute.

                  It would be a really a nice future, if richfaces is able to invoke server-side-methods within javascript-events like onmouseover, onexpand or the like.

                  <rich:contextMenu onexpand="#{myBean.doAction(a)}"..

                  Maybe, in future ..?!



                  • 6. Re: support action within rich:componentControl
                    nbelaevski

                    You can use a4j:support bound to onexpand for this.