You need to sign in to do that
Don't have an account?
![Jeff Decker Jeff Decker](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Embed Visualforce page into Standard Object to show/hide sections
HI Everybody,
I have a standard Implementation object that works very closely like the Opportunity object but has different stages and a few different fields. I'm trying to hide/show sections of this Implementation object based on what Stage was chosen out of this picklist. I'm able to get this working when I create a separate visualforce page with the code below but I'm having trouble embedding this in the Implementation object. I would rather not re-create an entirely custom Implementation object and just put some inline visualforce page into a section that takes care of this functionality.
When I embed my visualforce page it acts completely separate from the standard Implementation object. Here is my current visualforce code:
<apex:page standardController="Implementation__c" sidebar="true" tabStyle="Implementation__c">
<apex:form >
<apex:pageBlock title="Implementation">
<apex:pageBlocksection columns="2">
<apex:outputField value="{!Implementation__c.Name}"/>
<apex:outputField value="{!Implementation__c.Closed_Date__c}"/>
<apex:inputField value="{!Implementation__c.Stages__c}">
<apex:actionSupport event="onchange" reRender="ab, ac"/>
</apex:inputField>
</apex:pageBlocksection>
</apex:pageBlock>
<apex:outputpanel id="ab">
<apex:pageBlock title="Execution" rendered="{!Implementation__c.Stages__c == 'Execution I'}">
<apex:pageBlockSection >
<apex:pageblocksectionItem >
<apex:outputField value="{!Implementation__c.Next_Steps__c}"/>
</apex:pageBlocksectionItem>
</apex:pageBlocksection>
</apex:pageblock>
</apex:outputpanel>
<apex:outputpanel id="ac">
<apex:pageBlock title="Completion" rendered="{!Implementation__c.Stages__c == 'Completion'}">
<apex:pageBlockSection >
<apex:pageblocksectionItem >
<apex:outputField value="{!Implementation__c.Next_Steps__c}"/>
</apex:pageBlocksectionItem>
</apex:pageBlocksection>
</apex:pageblock>
</apex:outputpanel>
</apex:form>
</apex:page>
Thanks,
Jeff
I have a standard Implementation object that works very closely like the Opportunity object but has different stages and a few different fields. I'm trying to hide/show sections of this Implementation object based on what Stage was chosen out of this picklist. I'm able to get this working when I create a separate visualforce page with the code below but I'm having trouble embedding this in the Implementation object. I would rather not re-create an entirely custom Implementation object and just put some inline visualforce page into a section that takes care of this functionality.
When I embed my visualforce page it acts completely separate from the standard Implementation object. Here is my current visualforce code:
<apex:page standardController="Implementation__c" sidebar="true" tabStyle="Implementation__c">
<apex:form >
<apex:pageBlock title="Implementation">
<apex:pageBlocksection columns="2">
<apex:outputField value="{!Implementation__c.Name}"/>
<apex:outputField value="{!Implementation__c.Closed_Date__c}"/>
<apex:inputField value="{!Implementation__c.Stages__c}">
<apex:actionSupport event="onchange" reRender="ab, ac"/>
</apex:inputField>
</apex:pageBlocksection>
</apex:pageBlock>
<apex:outputpanel id="ab">
<apex:pageBlock title="Execution" rendered="{!Implementation__c.Stages__c == 'Execution I'}">
<apex:pageBlockSection >
<apex:pageblocksectionItem >
<apex:outputField value="{!Implementation__c.Next_Steps__c}"/>
</apex:pageBlocksectionItem>
</apex:pageBlocksection>
</apex:pageblock>
</apex:outputpanel>
<apex:outputpanel id="ac">
<apex:pageBlock title="Completion" rendered="{!Implementation__c.Stages__c == 'Completion'}">
<apex:pageBlockSection >
<apex:pageblocksectionItem >
<apex:outputField value="{!Implementation__c.Next_Steps__c}"/>
</apex:pageBlocksectionItem>
</apex:pageBlocksection>
</apex:pageblock>
</apex:outputpanel>
</apex:form>
</apex:page>
Thanks,
Jeff
This should work... but I would like to see the metod flow in your controller.
Can you please post your controller class as well?
One way to do this is... You can save the picklist in the object and re-direct the whole page to the same page.
Simple re-render won't work as is will try to rerender only the section of the page but the page is embeded inside a stadard page as inline VF page.
If I can see your controller code I can get more idea on acheiving it.
Thanks
Guha.
I'm actually not using a custom Controller for this. My idea was that when the Stage picklist value is changed then the entire page will refresh and show/hide the desired section. This works when I run the visualforce page as a separate object.
However, when I embed this into my standard Implementation object I comment out the fields i'm creating above because I want to use the fields on the actual Implementation object. I also don't know how to get the ID's of the sections on the page to have it get hidden.
Hopefully you follow what i'm trying to do and that it is actually possible.
Thanks,
Jeff
I get it now... what you are trying to acheive here...
I tried the same way in my dev org.... It is working fine as expected.
Following are the step by step process i did for the mock up:
- Creating and obj - Implementation.
- Creating a field under Implementation -> Stages - Picklist [Execution I, Completion].
- Creating a vf page - just a copy paste of your code.
- Removed the vf code with "Next_step" field - Pls find the code below.
- Edited the page layout in implementation record page and added the vf page as inline page [fyi: placed the inline page under a separate new section on the pagelayout]
And its working. The rerendering is happening as expected. let me know if you have done any extra steps that may hinder the rerender of the actionsupport.I really appreciate your help. I'm able to get the functioniity of the Action:Support tag working correctly but when I embed this into the Implementation object I don't want to create an additional Stages field in my Visualforce page. I had that in my original code because I was testing to make sure I could get the functionality to work properly.
The main problem now is that I want to show a certain section on the Implementation object when I change the value in the original Implementation object Stages field. I can see in your example that it looks you have two Stages fields (One in the Implementation Detail section and one in the Implemention section) and I would like to remove one in my Visualforce code and just use the Stages field in the top portion of the page.
In my current setup I have to actually save the record before any section gets shown/hid. It almost like the visualforce code doesn't get executed when the initail page is loaded.
Thanks again for your help.
Jeff
I tried one scenario, i have created picklist field using custom functionality, upon changing the picklist value, the pageblocksection will show/hide.
Ex: If picklist value is fresher, then some other fields should show with pageblock and other Exp pageblocksection will be hidden and vice versa.
I have written code, but its not working. can anyone help me to meet my criteria.
Thanks in advance
Vf code:
<apex:page standardController="Contact" extensions="StudentData1" >
<apex:form >
<apex:pageBlock title="Rendering PageBlock sections" >
<apex:pageBlockSection columns="2" title="Student Data">
<apex:selectList value="{!StudentList}" size="1">
<apex:outputLabel value="Student:"/>
<apex:selectOptions value="{!list}">
<apex:actionSupport event="onchange" reRender="ab,bc"/>
</apex:selectOptions>
</apex:selectList>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:outputpanel id="ab">
<apex:pageBlock title="Fresher Details" rendered="{!list == 'Fresher'}">
<apex:pageBlockSection columns="2">
<apex:inputField value="{!contact.FirstName}" />
<apex:inputField value="{!contact.LastName}" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:outputpanel>
<apex:outputpanel id="bc">
<apex:pageBlock title="Experience Details" rendered="{!list == 'Exp'}">
<apex:pageBlockSection columns="2">
<apex:inputField value="{!contact.Email}" />
<apex:inputField value="{!contact.Phone}" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:outputpanel>
<apex:commandButton value="save" action="{!Save}" />
</apex:form>
</apex:page>
apex class:
public class StudentData1 {
public StudentData1(ApexPages.StandardController controller) {
}
public String StudentList {get;set;}
public List<SelectOption> getlist()
{
List<SelectOption> stulist = new List<SelectOption>();
stulist.add(new SelectOption('None','None'));
stulist.add(new SelectOption('fresher','Fresher'));
stulist.add(new SelectOption('Experience','Exp'));
return stulist;
}
public pageReference save()
{
return null;
}
}