+ Start a Discussion
kmccollkmccoll 

IDs and pageBlockButtons

This is a pretty minor issue but thougt I'd post anyway...

If I have a commandButton inside a pageBlockButtons section of a pageBlock with location left to the default of "both" then any ID I give the commandButton will be the same on the top button as the bottom button.

This is invalid HTML and means that I can't access that button from javascript.  IE and FF both behave much the same - they don't complain, but pick the top button only.

Anybody have a workaround?

Thanks
Kenny
jwetzlerjwetzler
You're right, and it should have been appending a "bottom:" to the ids in the bottom section.  I will log a bug for that.

Why not use two pageBlockButtons?

Code:
<apex:page id="thePage">
  <apex:form id="theForm">
      <apex:pageBlock id="theBlock">
          <apex:pageBlockButtons location="top" id="theButtons">
              <apex:commandButton value="click" id="clickMe"/>
          </apex:pageBlockButtons>
          <apex:pageBlockButtons location="bottom" id="theBottomButtons">
              <apex:commandButton value="click" id="clickMe"/>
          </apex:pageBlockButtons>
      </apex:pageBlock>
  </apex:form>
</apex:page>

 then you can access both "thePage:theForm:theBlock:theButtons:clickMe" and "thePage:theForm:theBlock:theBottomButtons:clickMe".

kmccollkmccoll
Thanks - I always seem to miss the obvious workarounds.  That will do fine for now.