0

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()!

1

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>
| improve this answer | |
  • I did not get it, can you please write it in my case? – manchesterunited Jul 17 '17 at 11:46
  • @manchesterunited i edited... – farman k Jul 17 '17 at 12:24
0

apex:commandButton rendered attribute takes a boolean condition and based on the boolean condition value the button will get rendered in UI.

In your case lets say you have a controller variable status and you only want to show the button if status = 'pending' then.

 <apex:commandButton onclick="appendSelected(); return false;" value="Select" 
 rendered="{!testResultObj=='Pending'}"/>
  1. If testResultObj is pending, the condition evaluates to true and the button will get displayed in UI
  2. If testResultObj is not pending then the condition will evaluate to false and the button will not be visible.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.