Skip to content

Instantly share code, notes, and snippets.

@pchittum
Created November 19, 2015 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pchittum/6d47483a0b2f82e735f5 to your computer and use it in GitHub Desktop.
Save pchittum/6d47483a0b2f82e735f5 to your computer and use it in GitHub Desktop.
Rerender Example in Visualforce
<apex:page standardController="Position__c" title="Sample Position Layout Page" showHeader="true" sidebar="true" >
<apex:sectionHeader title="{!$ObjectType.Position__c.label} Edit" subtitle="New Position"/>
<chatter:feedWithFollowers entityId="{!Position__c.id}"/>
<apex:form id="theForm">
<!--this is the level I am rerendering at...including all sections and children-->?
<apex:pageBlock title="Position Detail" mode="edit" id="thePageBlock">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}" immediate="true"/>
</apex:pageBlockButtons>
<apex:pageBlockSection id="detail" title="Information" columns="2">
<!-- this field is also required...both at the field level, and in the markup-->
<apex:inputField required="true" value="{!Position__c.name}"/>
<apex:inputField value="{!Position__c.Priority__c}"/>
<apex:inputField value="{!Position__c.Location__c}"/>
<apex:inputField value="{!Position__c.Status__c}"/>
<apex:inputField value="{!Position__c.Type__c}"/>
<apex:inputField value="{!Position__c.Sub_Status__c}"/>
<apex:pageBlockSectionItem>
<apex:outputLabel value="{!$objecttype.Position__c.fields.Department__c.label}"></apex:outputLabel>
<!--this isolates the validated data-->
<apex:actionRegion >
<apex:inputField value="{!Position__c.Department__c}">
<apex:actionSupport event="onchange" rerender="thePageBlock"/>
</apex:inputField>
</apex:actionRegion>
</apex:pageBlockSectionItem>
<apex:inputField value="{!Position__c.Start_Date__c}"/>
<!--...more fields...-->
</apex:pageBlockSection>
<!-- this is the conditional section -->
<apex:pageBlockSection id="theSection" title="Technical Skills" columns="2" rendered="{!Position__c.Department__c == 'IT' || Position__c.Department__c == 'Engineering'}">
<apex:inputField value="{!Position__c.Operating_Systems__c}"/>
<apex:inputField value="{!Position__c.Programming_Languages__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Description" columns="1">
<!--this field is "Universally required" at the field level-->
<apex:inputField value="{!Position__c.Job_Description__c}" style="width:300px" />
<apex:inputField value="{!Position__c.Responsibilities__c}" style="width:300px" />
<apex:inputField value="{!Position__c.Skills_Required__c}" style="width:300px" />
<apex:inputField value="{!Position__c.Education__c}" style="width:300px" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment