3 Replies Latest reply on Jul 20, 2010 5:14 PM by nbelaevski

    modal panel buttons

    svkap

      Hello.

       

      I have some problems with my generated model panel buttons. My send button does not call the sendMessage Action method and my Cancel button does not close the model panel.

       

      JSF page:

       

      <f:subview>
          <rich:modalPanel id="sendMsgPnlPopId" keepVisualState="true" moveable="false" height="240" width="500">
              <f:facet name="header">
                  <h:panelGroup>
                      <h:outputText value="Send Message"></h:outputText>
                  </h:panelGroup>
              </f:facet>
              <f:facet name="controls">
                  <h:panelGroup>
                      <h:graphicImage id="hideMsgPopUplinkId" value="../img/close.png" styleClass="hidelink" />
                      <rich:componentControl for="sendMsgPnlPopId" attachTo="hideMsgPopUplinkId" operation="hide" event="onclick"/>
                  </h:panelGroup>
              </f:facet>
              <a4j:form id="send_message_form_id" binding="#{bean1.sendMessageForm}" />
          </rich:modalPanel>
      </f:subview>   
      

       

      Button initialization:

              HtmlAjaxCommandButton sendButton = new HtmlAjaxCommandButton();
              sendButton.setId("send_button_id_1");
              sendButton.setAjaxSingle(true);
              sendButton.setType("submit");
              sendButton.setValue("Send");
              sendButton.setStyleClass("SendMsg_SubmitButton");
              sendButton.setReRender(root.getId());
              MethodExpression btnSendActionExpression = expressionFactory
                      .createMethodExpression(elContext,
                              "#{sendMessageBean.sendMessage}", null,
                              new Class[] { ActionEvent.class });
              MethodExpressionActionListener listenerSend = new MethodExpressionActionListener(
                      btnSendActionExpression);
              sendButton.addActionListener(listenerSend);
              sendButton.setOncomplete("if (#{facesContext.maximumSeverity==null}) " +
                          "#{rich:component('sendMsgPnlPopId')}.hide();");
              
              HtmlAjaxCommandButton cancelButton = new HtmlAjaxCommandButton();
              cancelButton.setId("cancel_button_id_1");
              cancelButton.setAjaxSingle(true);
              cancelButton.setValue("Cancel");
              cancelButton.setStyleClass("SendMsg_SubmitButton");
              cancelButton.setOnclick("#{rich:component('sendMsgPnlPopId')}.hide();");
      

       

      Action:

      public void sendMessage(ActionEvent event) {
              System.out.println("################");
      }
      
        • 1. Re: modal panel buttons
          nbelaevski

          Hi Svetoslav,

           

          You are not configuring components properly. This code:

           

          sendButton.setOncomplete("if (#{facesContext.maximumSeverity==null}) " +
                              "#{rich:component('sendMsgPnlPopId')}.hide();");

          will cause JS error when executed. You should be creating ValueExpression and using it, but not the string containing EL-expressions as you do.

          • 2. Re: modal panel buttons
            svkap

            Hi Nick,

             

            setOncomplete accepts only String. Can you please give me an example?

             

            Thank you.

            • 3. Re: modal panel buttons
              nbelaevski

              Sure, use component.setValueExpression("oncomplete", expression).