• Rahul Gupta 176
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
public class AccListCon 
 {
    public List<Account> listAccount { get; set; }
    public integer blockSize;
    public integer offSetVar;
    public integer total_size;
    
    public AccListCon()
      {    
        offSetVar =0;
        blockSize =10;
        listAccount = [Select id, Name,BillingCity,Custom_Emaail__c ,OwnerId,phone from Account limit:blockSize  ];
        total_size=[select count() from account];
        //isbtnEnable = true;
     }
     
     public PageReference funPagination()
     {
        listAccount = [Select id, Name,BillingCity,Custom_Emaail__c ,OwnerId,phone from Account limit:blockSize offset:offSetVar ];
        return null;
    }
    
    
    public PageReference goToFirst() 
    {
        funPagination();
        offSetVar=0;
        return null;
    }
    
    
    
    public PageReference goToPrev() 
    {
        funPagination();
        if(offSetVar>0)
        {
        offSetVar=offSetVar-blockSize;
        }
        else 
         ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'This is last page of list '));
         return null;
    }
    
    public PageReference goToNext() 
    {
        funPagination();
        offSetVar=offSetVar+ blockSize; 
        isbtnEnable = true;     
        return null; 
        
    }   
    public PageReference goToLast() 
    {
       funPagination();
        if (offSetVar + blockSize < total_size) 
        {
        offSetVar = total_size - math.mod(total_size, blockSize);
        }
        else 
         ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'This is last page of list '));
       return null;
    }
}
-------------------------------------------------------------------------------------------
<apex:page controller="AccListCon">
 <apex:form >
      <apex:pageBlock >
      <apex:pageMessages ></apex:pageMessages>

    <apex:pageblockSection >
        <apex:pageBlockTable id="tblId" value="{!listAccount}" var="acc">
        <apex:column value="{!acc.id}"/>
            <apex:column value="{!acc.name}"/>
        
        </apex:pageBlockTable>
       
      </apex:pageblockSection>
       <apex:pageblockButtons >
         <apex:commandButton action="{!goToFirst}" reRender="tblId" disabled="{!isbtnEnable}" value="<<"/>
         <apex:outputPanel id="btnPanelId">
            <apex:commandButton id="btn1" action="{!goToPrev}" reRender="tblId,btnPanelId" value="<"/>
            <apex:commandButton action="{!goToNext}" reRender="tblId,btnPanelId,btn1" value=">"/>
            <apex:commandButton action="{!goToLast}" reRender="tblId,btnPanelId" value=">>"/>
            </apex:outputPanel>
        </apex:pageblockButtons>
      </apex:pageBlock> 
    </apex:form>
</apex:page>

So please help me with the test class i am unable to write 
<apex:page standardController="Contact"  sidebar="false" >
  <apex:form >
    <apex:pageBlock title="Edit Contact">
      <apex:pageBlockSection columns="1">
         <apex:inputField value="{!Contact.FirstName}"/>
         <apex:inputField  value="{!Contact.LastName}"/>
         <apex:inputField value="{!Contact.Email}"/>
         <apex:inputField value="{!Contact.Birthdate}"/>
         <apex:inputField type="number" value="{!Contact.Phone}"/>
      </apex:pageBlockSection>

      
    <apex:pageBlockButtons >
         <apex:commandButton action="{!save}" value="Save"/>
    </apex:pageBlockButtons>
   
    </apex:pageBlock>
  
   </apex:form>
  
</apex:page>

I want to validate the phone field that it should have 10 digits only and last name should have text only so how to use extension . 
Not getting way to do it . 
Please help 
<apex:page controller="clsAccountControl" >

<apex:form >
        <apex:pageBlock title="Account Details" >
            <apex:pageBlockTable value="{!acclist}" var="a" id="mid" >
            
                <apex:column value="{!a.Name}" headerValue="Account Name" />
                
                 <apex:column value="{!a.OwnerId }" headerValue="Owner" />
                <apex:column value="{!a.Custom_Emaail__c }" headerValue="Email" />
                
                <apex:column value="{!a.BillingCity }" headerValue="BillingCity " />
                
            </apex:pageBlockTable>
           
        </apex:pageBlock>
        
    </apex:form>

  
</apex:page>





-------------------------------------------------------------------
public class clsAccountControl 
{

 public List<Account> acclist {set;get;}
 
 public clsAccountControl()
 {
     acclist=[Select Name,BillingCity,Custom_Emaail__c ,OwnerId from Account LIMIT 10 OFFSET 10];
 }
 
 
 
  
}

 
<apex:page standardController="Contact"  sidebar="false" >
  <apex:form >
    <apex:pageBlock title="Edit Contact">
      <apex:pageBlockSection columns="1">
         <apex:inputField value="{!Contact.FirstName}"/>
         <apex:inputField  value="{!Contact.LastName}"/>
         <apex:inputField value="{!Contact.Email}"/>
         <apex:inputField value="{!Contact.Birthdate}"/>
         <apex:inputField type="number" value="{!Contact.Phone}"/>
      </apex:pageBlockSection>

      
    <apex:pageBlockButtons >
         <apex:commandButton action="{!save}" value="Save"/>
    </apex:pageBlockButtons>
   
    </apex:pageBlock>
  
   </apex:form>
  
</apex:page>

I want to validate the phone field that it should have 10 digits only and last name should have text only so how to use extension . 
Not getting way to do it . 
Please help 
<apex:page controller="clsAccountControl" >

<apex:form >
        <apex:pageBlock title="Account Details" >
            <apex:pageBlockTable value="{!acclist}" var="a" id="mid" >
            
                <apex:column value="{!a.Name}" headerValue="Account Name" />
                
                 <apex:column value="{!a.OwnerId }" headerValue="Owner" />
                <apex:column value="{!a.Custom_Emaail__c }" headerValue="Email" />
                
                <apex:column value="{!a.BillingCity }" headerValue="BillingCity " />
                
            </apex:pageBlockTable>
           
        </apex:pageBlock>
        
    </apex:form>

  
</apex:page>





-------------------------------------------------------------------
public class clsAccountControl 
{

 public List<Account> acclist {set;get;}
 
 public clsAccountControl()
 {
     acclist=[Select Name,BillingCity,Custom_Emaail__c ,OwnerId from Account LIMIT 10 OFFSET 10];
 }
 
 
 
  
}