2

Click this button should rerender my output panel and display the latest saved value - correct?

<apex:page standardController="Reject_Lead__c"  cache="false" showHeader="true" sidebar="true">
<apex:form >  
       <apex:outputPanel id="thePanel">
            <apex:outputField value="{!Reject_Lead__c.RL_LeadStatus__c}"/>
       </apex:outputPanel>

    <apex:commandButton action="{!null}" rerender="thePanel" value="FIRE!"/>
</apex:form>
</apex:page>

Any ideas?

3 Answers 3

1

The documentation for the action attribute on apex:commandButton states:

If an action isn't specified, the page simply refreshes

So all you need to do is remove action="{!null}" from your command button as shown below:

<apex:commandButton rerender="thePanel" value="FIRE!"/>
0

While this seems to be fine

rerender="thePanel"

your action function

action="{!null}" 

looks very strange to me. Rerender is coupled to an actionFunction you should/must provide.

Do you have an action function in the controller? Does your code work?

3
  • I only want to trigger the refresh of the output panel. No save or updates, just surface the data stored Nov 27, 2014 at 16:05
  • No problem, but you still need to provide an action function and it would just return null. It goes like public PageReference DoNothing() { return null; }
    – RichardT
    Nov 27, 2014 at 16:09
  • Thanks Richard, I was trying to escape writing controller stuff. What I actually want to do is rerender a single row in my pageblocktable. But thats one for another day. Thanks again Nov 27, 2014 at 23:40
0

This works for checking rerender attribute of commandButton works with outputPanel or not :-

public class CustomController{
    public integer i;
    public CustomController() {i = 1;}
    public integer getI() {return i;}
    public void calculate() {i = i + 1;} 
}

VF page which uses above custom controller :-

<apex:page controller="CustomController">
  <apex:form >
    <apex:commandButton value="Increment" action="{!calculate}" rerender="Panel1"/>
    <apex:outputPanel id="Panel1">
      <apex:outputText value="{!i}"/>
    </apex:outputPanel>
  </apex:form>
</apex:page>

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.