Friday, June 1, 2012

actionRegion tag in Visual force


Apex: actionRegion tag in Visual force:
     
       This action tag is use AJAX request for particular field or component. Like we have change the value of pick list in visual force then request go to Server and come back through AJAX without Saving the VF page.
    Also when we fill the VF page and we forget one of the field/pick list which is mandatory so before submitting Visual force page this field shows error line comments like “Error: You must enter a value” by action Region tag.
    This action tag will be for particular field only as reference given below VF code for Action Region tag.https://Salesforce_instance/apex/myPage?id=001D000000IRt53
where id is Opportunity’s Id.

Visual force page code:
<apex:page standardController="Opportunity">
<apex:form >
<apex:pageBlock title="Edit Opportunity" id="thePageBlock" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:inputField value="{!opportunity.name}"/>
<apex:pageBlockSectionItem >
<apex:outputLabel value="{!$ObjectType.opportunity.fields.type.label}" for="type"/>
<apex:inputField value="{!opportunity.type}" id="type"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="{!$ObjectType.opportunity.fields.stageName.label}" for="stages"/>
<apex:actionRegion >
<apex:inputField value="{!opportunity.stageName}" id="stage">
<apex:actionSupport event="onchange" rerender="thePageBlock" status="status"/>
</apex:inputField>
</apex:actionRegion>
</apex:pageBlockSectionItem>
<apex:inputfield value="{!opportunity.closedate}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

No comments:

Post a Comment