2 Replies Latest reply on May 19, 2009 5:40 PM by nbelaevski

    Problem with a4j:commandButton

    bwilliam

      Hi,
      I have a problem with a4j:commandButton not executing it's action when placed after a data table see source below:


      <table cellpadding="0" cellspacing="0" width="100%">
       <tr>
       <td class="body-main-wide" style="height: 630px;">
      
       <h2>Agronomists Portal</h2>
       <h:form>
      
       <%-- THIS COMMAND BUTTON WORKS CORRECTLY: generalBean.takeIrrigatorSelection is executed --%>
      
       <a4j:commandButton value="Select Party"
       action="#{generalBean.takeIrrigatorSelection}" onclick="Richfaces.hideModalPanel('IrrigatorSelectMp')"
       oncomplete="javascript:Richfaces.showModalPanel('IrrigatorPropertyMp');"/>
      
       </h:form>
       <h:form>
       <%-- Modal panel for irrigator selection --%>
       <rich:modalPanel id="IrrigatorSelectMp"
       showWhenRendered="true" height="395">
       <f:facet name="header">
       <h:outputText value="Select Irrigator" />
       </f:facet>
       <f:facet name="controls">
       <h:commandLink value="Close" style="cursor:pointer"
       onclick="Richfaces.hideModalPanel('IrrigatorSelectMp')" />
       </f:facet>
       <t:outputText>Please select an irrigator to use from the list below.</t:outputText>
       <h:form>
      
      
       <rich:scrollableDataTable id="irrDataTable" var="irrigator" value="#{generalBean.agronomistParties}" rendered="true"
       sortMode="single" height="305px"
       binding="#{generalBean.irrigatorDataTable}"
       selection="#{generalBean.selectedIrrigator}">
       <rich:column width="18">
       <h:graphicImage value="#{initParam.imagesDir}/user1-16.png" />
       </rich:column>
       <rich:column width="100">
       <f:facet name="header">
       <h:outputText value="Please select an irrigator." />
       </f:facet>
       <h:outputText value="#{irrigator.formalPartyName}" />
       </rich:column>
       </rich:scrollableDataTable>
      
      
       </h:form>
      
      
      
      
       <h:form>
      
       <%-- THIS COMMAND BUTTON DOES NOT WORK CORRECTLY: generalBean.takeIrrigatorSelection is NOT executed --%>
       <a4j:commandButton value="Select Party"
       action="#{generalBean.takeIrrigatorSelection}" onclick="Richfaces.hideModalPanel('IrrigatorSelectMp')"
       oncomplete="javascript:Richfaces.showModalPanel('IrrigatorPropertyMp');"/>
      
       </h:form>
      
       </rich:modalPanel>
      
      


      Can anybody tell me what is wrong here? I'm using RichFaces3.3.0 with myfaces 1.2.6 on Tomcat6. Thanks heaps for any feedback.

      Brett

        • 1. Re: Problem with a4j:commandButton
          shino

          I think I'm facing the same problem:

          <ui:composition xmlns="http://www.w3.org/1999/xhtml"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:a4j="http://richfaces.org/a4j"
           xmlns:rich="http://richfaces.org/rich">
          
           <ui:decorate template="templates/ModalPanel.xhtml">
           <ui:param name="param_Header" value="#{msgs.deleteAddress}" />
           <ui:param name="param_StyleClass" value="" />
           <ui:param name="param_ID" value="#{param_MP_ID}" />
          
           <ui:define name="mpContent">
           <h:form>
           <table width="400">
           <tbody>
           <tr>
           <td><br></br>
           <h:outputText value="#{msgs.reallyDeleteThisAddress}" /> <br></br>
           </td>
           </tr>
           <tr>
           <td><h:outputText
           value="#{addressbookController.currentAddress.name1},
           #{addressbookController.currentAddress.addressref}" />
           </td>
           </tr>
           <tr>
           <td align="center" width="50%"><a4j:commandButton
           id="ADDRESSBOOK_PORTLET_DELETEADDRESS_SUBMIT_A4J" type="submit"
           value="#{msgs.yes}" action="#{addressFormBacking.submit}"
           oncomplete="#{rich:component('deleteAddressPanel')}.hide();"
           reRender="#{param_ReRender}" /> <a4j:commandButton
           id="ADDRESSBOOK_PORTLET_DELETEADDRESS_CANCEL_A4J"
           value="#{msgs.cancel}"
           onclick="#{rich:component('#{param_MP_ID}')}.hide();return false;" />
           </td>
           </tr>
           </tbody>
           </table>
           </h:form>
           </ui:define>
           </ui:decorate>
          </ui:composition>


          Has anybody found a solution yet?

          best regards
          Chris

          • 2. Re: Problem with a4j:commandButton
            nbelaevski

            Hi Chris,

            Please add rich:messages and check if any were generated. Also check that forms are not nested - JSF forbids that.