3 Replies Latest reply on Jan 14, 2010 9:13 AM by Ilya Shaikovsky

    open a context-menu on inputText by right-click ?

    Frantz Degrigny Newbie
      Is it possible to open a context-menu on inputText by right-click ?
        • 1. Re: open a context-menu on inputText by right-click ?
          Ilya Shaikovsky Master
          <h:inputText id="input"></h:inputText>
          <rich:contextMenu event="oncontextmenu" attachTo="input" submitMode="none">
          <rich:menuItem value="menu item" ></rich:menuItem>
          </rich:contextMenu>
          checked and works fine for me.
          • 2. Re: open a context-menu on inputText by right-click ?
            Frantz Degrigny Newbie

            I am using a rich:componentControl because my inputs are in a dataTable and I dont want to repeat the context menu on each rows.

            The trick is don't forget to define the 'attachTo' attribute to be notified by the 'oncontextmenu' event. :

             

            <rich:contextMenu attached="false" id="menu" submitMode="server" disableDefaultMenu="true">
                              <rich:menuItem ajaxSingle="false" actionListener="#{myBean.copyValue}" >
                                Copy cell value to selected rows
                                <a4j:actionparam name="colCode" value="{colCode}"/>
                                <a4j:actionparam name="rowIndex" value="{rowIndex}"/>
                            </rich:menuItem>
               </rich:contextMenu>

             

            <rich:scrollableDataTable var="item" binding="#{myBean.dataTable}" value="#{myBean.products}"

             

                          <rich:columns value="#{myBean.colDecriptors}" var="col" >
                                            <f:facet name="header">
                                                <h:outputText value="#{col.label}" />
                                            </f:facet>
                                           
                                             <h:inputText id="#{col.propName}_input" value="#{item[col.propName]}" >
                                                <rich:componentControl event="oncontextmenu" for="menu" operation="show" attachTo="#{col.propName}_input">
                                                      <f:param value="#{myBean.dataTable.rowIndex}" name="rowIndex"/>
                                                      <f:param value="#{col.propName}" name="colCode"/>                                    
                                                  </rich:componentControl>                                                                      
                                            </h:inputText>

                           </rich:columns> 

             

            </rich:scrollableDataTable>

             

            What have confused me is that the 'onclick' an 'ondblclick' events work  well without the 'attachTo' attribute.

            • 3. Re: open a context-menu on inputText by right-click ?
              Ilya Shaikovsky Master
              if attached not defined - componetn control tried to be encoded as a4j:support directly to parent attribute. And input does not supports oncontextmenu