+ Start a Discussion
ClintHegneyClintHegney 

Issues with commandButton contained within HTML in a facet.

Anyone experiencing issues when putting a commandButton inside of some HTML inside of a facet?
dchasmandchasman
Clint,

There have been a number of issues fixed in Winter '08 w.r.t. the interaction of commandButtons and commandLinks inside facets. If you provide some details (e.g. the page markup) for the specific issue I can tell you if this is one of the known and fixed issues.

thanks,
ClintHegneyClintHegney
Code:
<apex:facet name="footer">
                <table border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td class="pbTitle">&nbsp;</td>
                    <td class="pbButtonb"><apex:commandButton styleClass="btn" action="{!save}" value="Save New Account Name"/></td>
                  </tr>
                </table>
            </apex:facet>

 The code above will fail and cause nothing to display in the footer facet at all.
mtbclimbermtbclimber
You need to nest a (single) component directly within your facet like so:

Code:
<apex:page>
  <apex:form>
    <apex:pageBlock>
      <apex:facet name="footer">
        <apex:panelGroup>
          <table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="pbTitle">&nbsp;</td>
              <td class="pbButtonb"><apex:commandButton styleClass="btn" value="Save New Account Name"/></td>
            </tr>
          </table>
        </apex:panelGroup>
      </apex:facet>
    </apex:pageBlock>
  </apex:form>
</apex:page>

 

Note: I removed the action attribute from commandButton in your example as I just whipped this up w/out a controller.
ClintHegneyClintHegney
Thank you, this worked. I assume that this is the same for a header facet as well.
mtbclimbermtbclimber
Yes it is, but before you spend a lot of time with this note that in Winter '08, due out very, very soon, we have simplified this tremendously.  I suspect this will do exactly what you are looking for:

Code:
<apex:page>
  <apex:form>
    <apex:pageBlock mode="edit">
      <apex:pageBlockButtons location="both">
        <apex:commandButton value="Save New Account Name"/>
      </apex:pageBlockButtons>
    </apex:pageBlock>
  </apex:form>
</apex:page>

mode="edit" on pageblock converts the styling to that of an edit page. mode="detail"  (the default)  give the block the styling of a detail page.

location="both" puts your buttons in both the header and footer.  This allows you to  easily specify the buttons you want to put in the expected location in the block while still specifying the title attribute on the pageBlock and not having to override the whole header or footer. You still can, of course, but most of the time this will probably do what you need.

Message Edited by mtbclimber on 10-23-2007 08:48 PM