4 Replies Latest reply on Apr 6, 2011 3:36 AM by lfryc

    a4j:commandButton, data called two times.

    pechnik

      I have h:form with a4j:commandButton in it. I use data property for calling bean method. When I press it my bean method calls several times.

       

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:rich="http://richfaces.org/rich"
                      xmlns:a4j="http://richfaces.org/a4j">
          <rich:popupPanel id="add_new_trader_modal_panel" modal="true"
                           width="370" minWidth="370"
                           autosized="true" resizeable="false" moveable="true" >
              <f:facet name="header">
                  <h:outputText value="Adding a new trader"
                                style="padding-right:20px;" />
              </f:facet>
              <h:form>
                  <h:panelGrid columns="1" columnClasses="centerText"
                               cellspacing="3px" width="100%" >
                      <h:outputText value="Type needed information about this trader: " />
                      <hr width="100%" size="1px"/>
                      <h:outputText value="" />
                      <h:outputText value="" />
                  </h:panelGrid>
                  <h:panelGrid columns="2" cellspacing="3px"
                               columnClasses="indexes, values" width="100%" >
                      <h:outputText value="Login name: " />
                      <h:inputText value="#{TradersDataController.newTrader.name}"
                                   maxlength="70" />
                      <h:outputText value="Password: " />
                      <h:inputText value="#{TradersDataController.newTrader.password}"
                                   maxlength="70" /> 
                  </h:panelGrid>
                  <hr width="100%" size="1px"/>
                  <h:outputText value="" />
                  <h:panelGrid columns="2" width="100%" columnClasses="centerText, centerText" >
                      <a4j:commandButton value="  Yes  "
                                         status="waitStatus"
                                         data="#{TradersDataController.doCreateTrader()}"
                                         oncomplete="if (data == 'Trader created successfully.') {Richfaces.hidePopupPanel('add_new_trader_modal_panel');} else {Richfaces.showPopupPanel('show_notification_add_trader');}"
                                         render="show_notification_add_trader, table_tr_wrapper"
                                         />
                      <a4j:commandButton value="Cancel"
                                         status="waitStatus"
                                         action="#{TradersDataController.clearNewTrader}"
                                         onclick="#{rich:component('add_new_trader_modal_panel')}.hide();return false;" />
                  </h:panelGrid>
              </h:form>
          </rich:popupPanel> 
      </ui:composition>
      
      

      What is wrong? And what method can be used instead of Richfaces.showModalPanel?