3 Replies Latest reply on Aug 14, 2009 6:38 PM by Nick Belaevski

    rich:menuitem with parameter

    tiger zhao Newbie

      subject: rich:menuitem with parameter


      I build a seam project with richfaces. In layout/menu.xhtml, I want to make a submenu with parameter, but it does not well.
      I click the menu first time, the page with no parameter. for example:[http://localhost:8080/quick/TblOperatorEdit.seam?cid=29]
      I click the menu second time, the page with the right parameter. for example: [http://localhost:8080/quick/TblOperatorEdit.seam?tblOperatorId=1&cid=29]
      Why? how can I get the right parameter or other suggestions?
      Thanks advance!

      tiger

      my code:

      <rich:dropDownMenu>
       <f:facet name="label">
       <h:panelGroup>
       <h:outputText value="personalSetting" />
       </h:panelGroup>
       </f:facet>
       <rich:menuItem submitMode="ajax" value="personalSetting"
       action="/TblOperatorEdit.xhtml"
       rendered="#{identity.loggedIn}">
       <f:param name="tblOperatorId" value="#{operator.id}" />
       </rich:menuItem>
       </rich:dropDownMenu>


        • 1. Re:  rich:menuitem with parameter
          Ilya Shaikovsky Master

          at richfaces demo it implemented in next way:

           public String getSkin() {
           String param = getSkinParam();
           if (param!=null) {
           setSkin(param);
           }
           return skin;
           }
          


          so before return actual skin we trying to lookup for request parameter:
           private String getSkinParam(){
           FacesContext fc = FacesContext.getCurrentInstance();
           String param = (String) fc.getExternalContext().getRequestParameterMap().get("s");
           if (param!=null && param.trim().length()>0) {
           return param;
           } else {
           return null;
           }
           }
          


          • 2. Re:  rich:menuitem with parameter
            tiger zhao Newbie

             

            "ilya_shaikovsky" wrote:
            at richfaces demo it implemented in next way:
             public String getSkin() {
             String param = getSkinParam();
             if (param!=null) {
             setSkin(param);
             }
             return skin;
             }
            


            so before return actual skin we trying to lookup for request parameter:
             private String getSkinParam(){
             FacesContext fc = FacesContext.getCurrentInstance();
             String param = (String) fc.getExternalContext().getRequestParameterMap().get("s");
             if (param!=null && param.trim().length()>0) {
             return param;
             } else {
             return null;
             }
             }
            


            sorry, I do not think it's what I want.

            I think maybe "#{operator.id}" does not work in the first click.
            but In authenticator.java:
            @Out(required = false, scope = ScopeType.SESSION)
             private TblOperator operator;
            operator is already defined and assigned after user login in.


            • 3. Re:  rich:menuitem with parameter
              Nick Belaevski Master

              Please check that #{operator.id} is not empty when link is being rendered.