1 Reply Latest reply on Feb 3, 2010 10:00 AM by martyphee

    a4j:commandButton - Disabling and enabling problems

    martyphee
      <a4j:commandButton value="Add New Report Distribution" id="add_report_distribution_button"
            disabled="#{rptDistCtlr.enabledAddButton}"
            reRender="add_edit_report_dist_panel"
            oncomplete="#{rich:component('add_edit_report_dist_panel')}.show();"
            action="#{rptDistCtlr.createReportDistribution}">
            <a4j:actionparam name="distReportId" value="#{rptDistCtlr.distReportId}"/>
      </a4j:commandButton>

      If I remove the "disabled" property the button behaves as expected and calls rptDisCtlr.createReport... Though if I do use the disabled property as above it just posts the page back and doesn't call my action. The button is disabled/enabled as expected and the rich:panel that it's within gets refreshed (there's a table inside it), but the action isn't called when I click the button to add a new Report.

      The html generated is the same.
      <input type="button" id="j_id61:add_report_distribution_button" name="j_id61:add_report_distribution_button" onclick="A4J.AJAX.Submit('j_id61',event,{'oncomplete':function(request,event,data){document.getElementById('add_edit_report_dist_panel').component.show();},'similarityGroupingId':'j_id61:add_report_distribution_button','parameters':{'distReportId':'1001','j_id61:add_report_distribution_button':'j_id61:add_report_distribution_button'} } );return false;" value="Add New Report Distribution" autocomplete="off" tabindex="0"/>

      <input type="button" id="j_id61:add_report_distribution_button" name="j_id61:add_report_distribution_button" onclick="A4J.AJAX.Submit('j_id61',event,{'oncomplete':function(request,event,data){document.getElementById('add_edit_report_dist_panel').component.show();},'similarityGroupingId':'j_id61:add_report_distribution_button','parameters':{'distReportId':'1011','j_id61:add_report_distribution_button':'j_id61:add_report_distribution_button'} } );return false;" value="Add New Report Distribution" autocomplete="off"/>

        • 1. Re: a4j:commandButton - Disabling and enabling problems
          martyphee

          Nevermind....

           

          The value of #{rptDistCtlr.enabledAddButton} was at the request level.  So each time the request was made it thought the button was disabled and it never called the action.  I made sure to check the state of the button on PostConstruct method and everything works fine now.

           

          I saw another post which mentioned something similar and it made me think about that.  I changed the bean scope to session and it worked so I just had to rework it a little to track the state of the button.