+ Start a Discussion
David VPDavid VP 

PageBlockButtons rerender bug ?

Hi,

When you use pageBlockButtons in a pageBlock, the page will display the buttons at both the top and the bottom of the pageBlock to which these buttons belong.

I wanted to disable the 'Save' button in a page untill some conditions were met using the 'disabled' attribute and rerender the button as 'enabled' whenever all checks in the controller come back ok.
Unfortunately, it seems that only the button at the top gets rerendered.

Looking at the attributes in the page I notice that both buttons got the same id but the Ajax javascript probably doesn't look for more than one match to rerender.

You can see this behaviour in the page and controller below :

<apex:page controller="buttontestController">
 
  <apex:form>
      <apex:pageblock>         
          <apex:pageblockButtons>
              <apex:commandButton value="Save" disabled="{!saveButtonDisabled}" id="savebutton"></apex:commandButton>
          </apex:pageblockButtons>
          <apex:outputlabel value="some page info"></apex:outputlabel>
          <apex:commandbutton value="Switch Save Button Rendering" action="{!someMethod}" rerender="savebutton"></apex:commandbutton>
      </apex:pageblock>
  </apex:form>
 
</apex:page>



public class buttontestController {
   
    Boolean saveButtonDisabled = false;
   
    public Boolean getSaveButtonDisabled() {
        return saveButtonDisabled;
    }
   
    public void someMethod() {
        if(saveButtonDisabled) {saveButtonDisabled = false;}
        else {saveButtonDisabled = true;}
    }

}

I guess this isn't supposed to happen ?
It's not urgent for me right now but if I come up with a workaround I'll post it here. If you've got one, feel free to do so too.


David
kmccollkmccoll
I had a similar issue.

It's a known issue, and Jill proposed the workaround of creating separate top and bottom buttons and handling both of them individually.  
David VPDavid VP
Thanks !

That should do it. (I had seen your post but overlooked the 'location' attribute in the pageBlockButtons component in your thread as well as in the reference.)