1 Reply Latest reply on Jul 5, 2012 7:35 AM by Be Mo

    ContextMenu with Ajax

    Be Mo Newbie

      Hi!

       

      I need some help with the context menu.

       

      What I want is a file explorer, e.g. showing icons for PDF and Word files.

      When you click on a file icon, a context menu should appear, showing the menu items

      "Open" (to open the file via Servlet, e.g. /OutputServlet?filename=selectedFile) and

      "Delete" to delete the file on the Server and rerender the file icons via Ajax

       

      This is what I have so far. It shows the icons and calls a generic action method.

      But I don't know how to select the current file for Open and to

      rerender the form after deleting a file.

       

      <h:form id="frmFiles" prependId="false">
          <ui:repeat value="#{filesView.docFilenames}" var="doc">
              <h:graphicImage id="imgDoc" name="images/word.jpg" alt="#{doc}" title="#{doc}"/>
              <rich:contextMenu target="imgDoc" mode="client" showEvent="click">
                  <!-- Here I want to open the file #{doc} via a Servlet /OutputServlet?filename=#{doc} -->
                  <rich:menuItem label="Open"   mode="ajax" action="#{filesView.openAction()}"/>
                  <!-- Here I need to delete the file and rerender this form -->
                  <rich:menuItem label="Delete" mode="ajax" action="#{filesView.deleteAction()}"/>
              </rich:contextMenu>
          </ui:repeat>
      </h:form>
      

          

      Thanks for listening.

       

      Bernd

        • 1. Re: ContextMenu with Ajax
          Be Mo Newbie

          Ok, I answer myself.

           

          The content menu should look like that:

           

          <rich:contextMenu target="imgDoc" mode="client" showEvent="click">
              <rich:menuItem label="Open" onclick="document.location.href='OutputServlet?filename=#{doc}'"/>
              <rich:menuItem label="Delete" mode="ajax" execute="frmFiles" render="frmFiles"
                             action="#{filesView.delete(doc)}"/>
          </rich:contextMenu>
          

           

          Bernd

          1 of 1 people found this helpful