Saturday, 7 May 2016

PAGEREFERENCE AND EXTENSION AND SOQL Using Custom Controller

PAGEREFERENCE AND EXTENSION AND SOQL Using Custom Controller


<apex:page controller="CallVfDemoController">
<apex:form>
<apex:pageBlock>
<apex:commandButton value="Call Contact Page" action="{!Callcontactpage}"/>
<apex:commandButton value="Call Acount Page" action="{!Call_VF_Page}"/>
</apex:pageBlock>
</apex:form>
</apex:page>



Public with sharing class CallVfDemoController {
 
  Public CallVfDemoController(){
  }
   
  Public pagereference Call_VF_Page(){
    PageReference openvfpage = New Pagereference('/apex'+'/DemovfPage');
    openvfpage.setRedirect(false); 
    return openvfpage ;
    return openvfpage ;
  }
  Public pagereference Callcontactpage(){
   PageReference openvfpage2 = New Pagereference('/apex'+'/DemovfPage2');
   openvfpage2.setRedirect(false); 
 return openvfpage2 ;
  }
  
  
}



<apex:pagestandardcontroller="Account" sidebar="false" showHeader="false">
<apex:form>
   Welcome TO PAge2
<apex:pageBlock Title="Account">
<apex:pageBlockButtons>
<apex:commandButton Value="Save" Action="{!save}"/>
<apex:commandButton Value="Edit" Action="{!edit}"/>
 
</apex:pageBlockButtons>
<apex:pageBlockSection Title="Records">
<apex:InputField value="{!Account.Name}"/>
<apex:InputField value="{!Account.Industry}"/>
 
 
 
 
 
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>


<apex:pagestandardcontroller="Registrations__c" extensions="Regsearch2">
<apex:form>
 
 
<apex:OutputLabel Value="Enter Name For Register User"></apex:OutputLabel>
<apex:Inputtext value="{!searchname}"/>
<apex:commandButton Value="Search" action="{!searchrecords}"/>
<apex:pageBlock>
<apex:pageBlockTable value="{!searchrecords}" var="y" >
<apex:column value="{!y.Id}"/>
<apex:column value="{!y.Account__c}"/>
<apex:column value="{!y.Email__c}"/>
<apex:column value="{!y.Name__c}"/>
 
 
 
</apex:pageBlockTable>
 
 
</apex:pageBlock>
 
 
 
</apex:form>
 
 
</apex:page>


Extension Controller with Soql _________________


Public with sharing class Regsearch2{

    public PageReference searchrecords() {
        return null;
    }
    
    Public Regsearch2(ApexPages.StandardController stdController){
    
    
    }

Public String searchname{set;get;}
Public List<Registrations__c> regs;

Public List<Registrations__c>  getsearchrecords(){
regs=[SELECT Id,Account__c,Email__c,Name__c,Sur_Name__c FROM Registrations__c Where Name__c=:searchname];
return regs;
}


}

RECORDSETVAR

<apex:pagestandardController="contact" recordSetVar="contacts" showHeader="false" sidebar="false">
<apex:form>
<apex:pageBlockTabStyle="Account" >
<apex:pageBlockTable value="{!contacts}" var="y">
<apex:column Value="{!y.Account.Name}"/>
<apex:column Value="{!y.Name}"/>
<apex:column Value="{!y.Phone}"/>
<apex:column Value="{!y.Email}"/>
 
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
 


No comments:

Post a Comment