Monday 20 January 2014

Display Account information with similar Industry

/*
*/
<apex:page controller="vf10controller">
<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:pageblocksection title="My account" >
            <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>
     

           <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>
-----------------------------
public class vf10controller {

    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;
    }
}
--------------------