0 Replies Latest reply on Sep 12, 2008 5:26 PM by Pedro Taborda

    Design Issues with Rich MenuItem done programatically firing

    Pedro Taborda Newbie

      First sorry for the short subject, this is the real situation:

      Due to company regulations I'm in charge to create the application menu using Java Code using as a control file an xml structure with the different options and the role associated with it (acting like a filter) now this whole process is fired once and only once during user's authentication. After experimenting with diferent algorithms I was able to genereted the HtmlToolbar with their corresponding childs according to a user's role. Next step is to perform different responds to user selection:

      1. Redirecting to a new xhtml screen. Done it with a backing bean method and using JSF navigation rules (still pending for improvement but pass the proof of concept demo).

      Accomplished using

      Menu.java

      /**
      * Ir a la Transaccion WFPL
      *
      */
      public String wfpl()
      {
      return "wfpa";
      }

      faces-config.xml

      <navigation-rule>

      Escritorio
      <display-name>
      /ui/sm/sm/sm00.xhtml</display-name>
      <from-view-id>/ui/sm/sm00.xhtml</from-view-id>
      <navigation-case>
      <from-action>#{SM00_Action.wfpa}</from-action>
      <from-outcome>wfpa</from-outcome>
      <to-view-id>/ui/wf/wfpa.xhtml</to-view-id>

      </navigation-case>
      </navigation-rule>

      The problem I think I may enconter is since the menu will be across all pages (different) views how to write the negivation rules in such a way to avoid to write the methos in all my backing beans for the pages? A global navigation rule system is possible?

      I think in implementing a class with all methods like the one above and all my backing beans (those that handle the pages) to inhered that class, but the xml for the navigation rule are still a problem


      2.- Opening a new browser

      Could be accomplished using javascript (perhaps using a outputlink?) If I create the HtmlMenuItem programatically perhaps creating a HtmlOutputLink object and executing this code will do the trick?

      menuItem.getChildren().add(link);


      3.- Opening Dialog Box

      I thinking in using a ModalPanel but created programatically using acode like this one:

      htmlMenuItem.setSubmitMode(menuItem_submitMode);

      if( null != menuItem_icon )
      {
      htmlMenuItem.setIcon(menuItem_icon);
      }

      if( null != elFactory )
      {
      methodExpression = elFactory.createMethodExpression(
      facesContext.getELContext(), menuItem_action,
      String.class, new Class[] { });

      if(debug)
      {
      log.debug("methodExpression"+methodExpression.getExpressionString());
      }

      htmlMenuItem.setActionExpression(methodExpression);


      Where submitMode is set to ajax and actionExpression pointing to the backing Bean
      #{SM00_Action.about}


      public HtmlModalPanel mmAyuda_AcercaDe()
      {
      HtmlModalPanel htmlModalPanel = new HtmlModalPanel();

      FacesContext facesContext = FacesContext.getCurrentInstance();

      HtmlPanelGroup htmlPanelGroupHeader;
      HtmlPanelGroup htmlPanelGroupControls;
      HtmlGraphicImage htmlGraphicImage;
      HtmlOutputText titulo;

      HtmlComponentControl htmlComponentControl;

      htmlModalPanel.setId("dlgAyuda_AcercaDe");
      htmlModalPanel.setHeight(200);
      htmlModalPanel.setWidth(350);

      /*
      * Titulo del Cuadro de Dialogo
      *
      * <h:panelGroup>
      * <h:outputText value="XXXXXX"></h:outputText>
      * </h:panelGroup>
      *
      */
      htmlPanelGroupHeader = new HtmlPanelGroup();

      htmlPanelGroupHeader.setId("dlgAyuda_AcercaDe-panel-header");
      htmlPanelGroupHeader.setRendererType("javax.faces.Group");

      titulo = new HtmlOutputText();
      titulo.setId("dlgAyuda_AcercaDe-titulo");


      if( null != facesContext )
      {
      titulo.setValue(I18lnUtil.getMessageResourceString(facesContext.getApplication()
      .getMessageBundle(), "ui-acercade-lblTitulo", null, facesContext.getViewRoot()
      .getLocale()));
      }
      else
      {
      titulo.setValue("ui-acercade-lblTitulo");
      }


      htmlPanelGroupHeader.getChildren().add(titulo);

      htmlModalPanel.getFacets().put("header", htmlPanelGroupHeader);

      /*
      * Icono para Cerrar el Dialogo
      *
      * <h:panelGroup>
      * <h:graphicImage value="/images/modal/close.png" style="cursor:pointer" id="hidelink"/>
      * <rich:componentControl for="panel" attachTo="hidelink" operation="hide" event="onclick"/>
      * </h:panelGroup>
      *
      */
      htmlPanelGroupControls = new HtmlPanelGroup();

      htmlPanelGroupControls.setId("dlgAyuda_AcercaDe-panel-controls");
      htmlPanelGroupControls.setRendererType("javax.faces.Group");

      htmlGraphicImage = new HtmlGraphicImage();
      htmlGraphicImage.setId("dlgAyuda_AcercaDe-icono-cerrar");
      htmlGraphicImage.setUrl("../recursos/imgs/icons/small/close.png");


      htmlComponentControl = new HtmlComponentControl();

      htmlComponentControl.setAttachTo("dlgAyuda_AcercaDe-icono-cerrar");
      htmlComponentControl.setFor("dlgAyuda_AcercaDe");
      htmlComponentControl.setOperation("hide");
      htmlComponentControl.setEvent("onclick");

      htmlPanelGroupControls.getChildren().add(htmlGraphicImage);
      htmlPanelGroupControls.getChildren().add(htmlComponentControl);

      htmlModalPanel.getFacets().put("controls", htmlPanelGroupControls);

      HtmlOutputText contenido = new HtmlOutputText();

      contenido.setValue("Hola Mundo ");

      htmlModalPanel.setValue(contenido);




      return htmlModalPanel.;

      }





      The problemI have is the code is executing by the JBoss server not output is generated, I not an expert in JSF but I having problems in understanding the functionality of Rich Faces without extensive Java code examples.


      Thanks,
      Pedro Taborda