This is a simple rendering of detail record of that you selected.Here action support function is main since it refreshed by the server when a particular event occurs.
Here is the controller
public with sharing class DynamicDetail
{
public String chosenAccountId {get; set;}
public List<SelectOption> getAccounts()
{
List<SelectOption> accOptions=new List<SelectOption>();
accOptions.add(new SelectOption('Choose', 'Choose'));
for (Account acc : [select id, Name from Account ])
{
accOptions.add(new SelectOption(acc.id, acc.Name));
}
return accOptions;
}
}
and the page looks like this
<apex:page controller="DynamicDetail" tabstyle="Account" sidebar="false">
<apex:form >
<apex:pageblock title="Choose Account">
<apex:pageBlockSection >
<apex:selectList value="{!chosenAccountId}" size="1">
<apex:selectOptions value="{!accounts}" />
<apex:actionSupport event="onchange" rerender="detail" status="detailstatus"/>
</apex:selectList>
</apex:pageBlockSection>
</apex:pageblock>
<apex:pageBlock title="Account Preview">
<apex:actionStatus id="detailstatus">
<apex:facet name="start">
<apex:outputText value="Please wait ..."/>
</apex:facet>
<apex:facet name="stop">
<apex:outputPanel id="detail">
<apex:detail subject="{!chosenAccountId}" rendered="{!NOT(ISBLANK(chosenAccountId))}"
relatedList="false"/>
</apex:outputPanel>
</apex:facet>
</apex:actionStatus>
</apex:pageBlock>
</apex:form>
</apex:page>

No comments:
Post a Comment