Salesforce Real Time Tasks:
Scenario:
Solution:
Visualforce Page:
Apex Controller:
Result:
Scenario:
Some time we will get a requirement to Display the all the records in objects and whenever select one Record Then Display the Detail page of that Record and Show the Similar Records with Same Industry Type.
Visualforce Page:
<apex:page controller="rtt5"> <apex:form > <apex:pageBlock > <apex:pageBlockButtons > <apex:commandButton value="Customer Direct Account" action="{!direct}"/> <apex:commandButton value="Customer - Channel Account" action="{!channel}"/> </apex:pageBlockButtons> <apex:pageblocktable value="{!acts}" var="row" > <apex:column > <apex:commandLink value="{!row.name}" action="{!racts1}" rerender="abc"> <apex:param value="{!row.id}" name="aid"/> <apex:param value="{!row.name}" name="aname"/> <apex:param value="{!row.industry}" name="aindustry"/> </apex:commandLink> </apex:column> <apex:column value="{!row.type}"/> <apex:column value="{!row.industry}"/> </apex:pageblocktable> <apex:pageblocksection title="{!$CurrentPage.parameters.aname}" id="abc"> <apex:detail subject="{!$CurrentPage.parameters.aid}"/> <apex:pageblocktable value="{!racts}" var="row" > <apex:column value="{!row.Name}"/> <apex:column value="{!row.type}"/> <apex:column value="{!row.industry}"/> </apex:pageblocktable> </apex:pageblocksection> </apex:pageBlock> </apex:form> </apex:page>
Apex Controller:
public class rtt5{ List<Account> r_acts; // string type; List<Account> acts = [SELECT name,type,industry,phone,ownerid FROM Account ]; public List<Account> getacts(){ return acts; } public List<Account> getracts(){ return r_acts ; } public PageReference direct(){ //type = 'Customer - Direct'; acts = [SELECT name,type,industry,phone,ownerid FROM Account WHERE Type ='Customer - Direct']; return null; } public PageReference channel(){ // type = 'Customer - Channel'; acts = [SELECT name,type,industry,phone,ownerid FROM Account WHERE Type = 'Customer - Channel']; return null; } public pagereference racts1(){ r_acts =[SELECT name,type,industry,phone,ownerid FROM Account WHERE Industry =: ApexPages.CurrentPage().getParameters().get('aindustry') ]; return null; } }
Result: