Use Case: Display Quote Property
This use case walks you through using the PropertyComponent to display the property view for the Quote object creation page. The high level steps are:
Build a Field Set
The PropertyComponent uses a field set to build up the quote creation page. Create a field set you want to use in the PropertyComponent.
Implement the Apex Controller
In your controller, make a public property of type
PropertyComponentOptions
and build it in the controller's constructor as shown in the sample code below:Implement the Visualforce Page
On your VisualForce page, embed the component and pass in the PropertyComponentOptions property from the controller as shown in the below sample code. Make sure the component is within the <apex:form/>
tag.
<apex:page standardController="zqu__Quote__c" title="Property Component Sample" extensions="PropertyComponentSampleController" sidebar="true" showHeader="true"> <apex:sectionHeader title="Property Compoment" subtitle="Sample" id="quoteTitle" /> <apex:form id="quoteForm"> <zqu:PropertyComponent options="{!theOptions}"> <!-- Custom Rendered Fields --> <apex:outputPanel styleClass="customRenderedFieldPanel" rendered="{!IF(field.name == 'Custom_Picklist_Field__c', true, false)}"> <apex:outputPanel style="float: left; padding-top: 0px; width: {!IF(fieldSet.isSingleColumn, '17.1%','34.5%')};" styleClass="labelCol"> <apex:outputLabel style="margin-right: 10px;">{!field.label}</apex:outputLabel> </apex:outputPanel> <apex:inputField value="{!quote.Custom_Picklist_Field__c}" required="{!field.isRequired}" onchange="displayStatusModal();changeCustomPicklist(this.options[this.selectedIndex].value);" /> </apex:outputPanel> <apex:outputPanel id="customTextField" styleClass="customRenderedFieldPanel" rendered="{!IF(field.name == 'Custom_Text_Field__c', true, false)}"> <apex:outputPanel style="float: left; padding-top: 0px; width:{!IF(fieldSet.isSingleColumn, '17.1%','34.5%')};" styleClass="labelCol"> <apex:outputLabel style="margin-right: 10px;">{!field.label}</apex:outputLabel> </apex:outputPanel> <apex:inputField value="{!quote.Custom_Text_Field__c}" required="{!field.isRequired}"/> </apex:outputPanel> </zqu:PropertyComponent> <!-- Action Function for re-rendering custom fields --> <apex:actionFunction name="changeCustomPicklistValue" action="{!onChangeCustomPicklist}" rerender="notificationPanel,customTextField" immediate="true" oncomplete="javascript:closeStatusModal();"> <apex:param assignTo="{!selectedCustomPicklistValue}" value="" name="val"/> </apex:actionFunction> <script> function changeCustomPicklist(val){ changeCustomPicklistValue(val); } </script> </apex:form> </apex:page>