[SalesForce] Render in Command Button

I have a question on how to use render on command button?

<apex:pageBlockButtons >
    <apex:commandButton onclick="appendSelected(); return false;" value="Select" />
    <apex:commandButton onclick="appendSelected1(); return false;" value="Select"/>

</apex:pageBlockButtons>

I want to restrict appendselectedfunction() on appendselected1()!

Best Answer

Putting an inside your tags and using that as the rerender target makes the page work as expected:

First of all you need to remove the renderRegionOnly attribute on your actionRegion component -- that is not doing what you think it's doing. Simply surrounding your inputField with an actionRegion will submit only that inputField without submitting the values outside of it (as you've alluded to in your HTML comment).

Whatever you want to be conditionally rendered should have rendered="{!Opportunity.StageName != 'Qualification'}" because that is the expression that will be evaluated whenever that component is created or updated.

And then finally, the target of what you are rerendering needs to always be on your page -- in more basic terms, whatever id you specify in rerender="someId" cannot be on the same component that has the rendered="{!Opportunity.StageName != 'Qualification'}" on it. So if you want your outputPanel conditionally rendered, it can't be the target of your rerender attribute. You may need to put it inside of another outputPanel. For more explanation see this https://developer.salesforce.com/forums?id=906F000000094hvIAA

<apex:pageBlockButtons location="bottom" id="d">
<apex:outputPanel id="buttons">
       <apex:commandButton onclick="appendSelected(); return false;" value="Select" rendered="{!selectId=='show'}"/>
       <apex:commandButton onclick="appendSelected1(); return false;" value="Select" rendered="{!selectId=='show'}"/>        
</apex:outputPanel>
</apex:pageBlockButtons>
Related Topic