• navy11jain@hotmail.com
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hi Rajat,
this is code below i modofied and it's working oerfectly as you are expecting:

<apex:page standardcontroller="Account" extensions="StudentsControllernew"  >
 
<script>
alert("Checkvalue");
alert({!acctSSC});
function displayErr(){
      window.alert("Checkvalue:");
}
</script>
  
    <apex:form id="theForm" >

        <apex:inlineEditSupport />
  
        <apex:pageBlock Title="All Students List" id="pbAccts">
          
            <apex:pageblockbuttons location="bottom">
                <apex:commandbutton action="{!saveAccounts}" value="Save" id="saveButton"  />
                <apex:commandbutton value="Cancel" action="{!cancel}"/>
            </apex:pageblockbuttons>
          
            <apex:pageBlockTable value="{!acclist}" var="a" >
            <!--    <apex:column value="{!a.name}"/>
                <apex:column value="{!a.website}"/>
                <apex:column value="{!a.phone}"/> -->
                 <apex:column headerValue="Name">
            <apex:outputField value="{!a.Name}"/>
         </apex:column>
         <apex:column headerValue="Phone">  
            <apex:outputField value="{!a.phone}">
               <apex:inlineEditSupport showOnEdit="saveButton" event="ondblclick"/>   
            </apex:outputField>
          </apex:column> 
           <apex:column headerValue="website">  
            <apex:outputField value="{!a.website}">
               <apex:inlineEditSupport showOnEdit="saveButton" event="ondblclick"/>   
            </apex:outputField>
          </apex:column>
            </apex:pageBlockTable>
             
        <br/>
      
        <apex:outputText value="Please select the number of records to be displayed : "/>
                  
            <apex:selectList size="1" value="{!pageSize}">
                <apex:selectOptions value="{!pageSizes}"/>
                      <apex:actionSupport event="onchange" action="{!updateStandardSetController}" rerender="theForm"/>
            </apex:selectList>
          
            <apex:outputPanel layout="block" styleClass="pSearchShowMore" id="otpNav2">
              
            <!-- <apex:outputText rendered="{!IF(acctSSC.resultSize < 10000,true,false)}"> <b> TOTAL </b> : {!acctSSC.resultSize} &nbsp;&nbsp;&nbsp; </apex:outputText> -->
              
                <apex:commandLink value="Previous Page " action="{!previous}" rendered="{!acctSSC.HasPrevious}" rerender="pbAccts" /> 
                <apex:outputPanel style="color: grey;" rendered="{!NOT(acctSSC.HasPrevious)}">Previous Page &nbsp; </apex:outputPanel>       
                <apex:outputPanel style="color:grey;" rendered="{!NOT(acctSSC.HasNext)}">Next Page</apex:outputPanel>       
                <apex:commandLink action="{!next}" value="Next Page" rendered="{!acctSSC.HasNext}" rerender="pbAccts"/>
    
            </apex:outputPanel>
          
        </apex:pageBlock>  
      
    </apex:form>
  
</apex:page>

public class StudentsControllernew {

        public String message{get;set;}
        public list<account> acclist {get;set;}
       
       public StudentsControllernew(ApexPages.StandardController controller){
        pageSize = '5';
        acclist = [SELECT Id, name, website, phone FROM Account limit 50000];
        updateStandardSetController();
    }

    //Page record size variable
   public string pageSize {get;set;}
  
    //Standard Set Controller variable for taking all students records (Standard Set controllers methods will be used for working with the collection of records - like pagination)
    public ApexPages.Standardsetcontroller acctSSC {get;set;}
  
    //Constructor will set the default page size of records and also call the method to fetch records  
     
    //Method to fetch records and display only page size records
    public void updateStandardSetController(){
      //   acclist = [SELECT Id, name, website, phone FROM Account limit 50000];
       acctSSC = new ApexPages.Standardsetcontroller(Database.getQuerylocator([SELECT Id, name, website, phone FROM Account]));
       acctSSC.setPageSize(integer.valueOf(pageSize));
       //update acclist;
      // return null;
    }
  
    //Method to get all records on to the page
  //  public List<Account> getAccounts(){
//       return acclist;
  //  }
  
    //Method to set the number of records on the page to be displayed as per user option
    public List<SelectOption> getPageSizes(){
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('5','5'));
        options.add(new SelectOption('10','10'));
        options.add(new SelectOption('20','20'));
        options.add(new SelectOption('50','50'));
        options.add(new SelectOption('100','100'));
        return options;
    }
  
    //Returns true/false based on records present or not
    public Boolean hasNext{
        get{
            return acctSSC.getHasNext();
        }
        set;
    }

    //Returns true/false based on records present or not
    public Boolean hasPrevious{
        get{
            return acctSSC.getHasPrevious();
        }
        set;
    }

    //Returns previous page of records if present
    public void previous(){
        acctSSC.previous();
    }

    //Returns next page of records if presen
    public void next(){
        acctSSC.next();
    }
    public pagereference saveAccounts(){     
        try{
         update acclist;
         PageReference nextpage= new PageReference('/apex/accounteditingfinal');
          nextpage.setredirect(true);
           return nextpage;
      }
      catch(Exception e){
            message='Data Base error during saving...';
            ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.ERROR, message));
            return null;
        }  
   }
     
}

if it's wothfull please mark it as a solution.

I have to count Campaign history Record in custom field on person account. I don't know how we can achieve this.

Please Give me Your suggestions or any idea anybody have

 

Thanks in advance.

Hi Guys

This is the code i have : 

PAGE :

<apex:page standardcontroller="Account" extensions="StudentsController" >
  
<script>
alert("Checkvalue");
alert({!acctSSC});
function displayErr(){
      window.alert("Checkvalue:");
}
</script>
   
    <apex:form id="theForm">

        <apex:inlineEditSupport />
   
        <apex:pageBlock Title="All Students List" id="pbAccts">
           
            <apex:pageblockbuttons location="bottom">
                <apex:commandbutton value="Save" action="{!saveAccounts}" onclick="dislayErr()" />
                <apex:commandbutton value="Cancel" action="{!cancel}"/>
            </apex:pageblockbuttons>
           
            <apex:pageBlockTable value="{!accounts}" var="a">
                <apex:column value="{!a.name}"/>
                <apex:column value="{!a.website}"/>
                <apex:column value="{!a.phone}"/>
            </apex:pageBlockTable>
              
        <br/>
       
        <apex:outputText value="Please select the number of records to be displayed : "/>
                   
            <apex:selectList size="1" value="{!pageSize}">
                <apex:selectOptions value="{!pageSizes}"/>
                      <apex:actionSupport event="onchange" action="{!updateStandardSetController}" rerender="theForm"/>
            </apex:selectList>
           
            <apex:outputPanel layout="block" styleClass="pSearchShowMore" id="otpNav2">
               
            <!-- <apex:outputText rendered="{!IF(acctSSC.resultSize < 10000,true,false)}"> <b> TOTAL </b> : {!acctSSC.resultSize} &nbsp;&nbsp;&nbsp; </apex:outputText> -->
               
                <apex:commandLink value="Previous Page " action="{!previous}" rendered="{!acctSSC.HasPrevious}" rerender="pbAccts" />  
                <apex:outputPanel style="color: grey;" rendered="{!NOT(acctSSC.HasPrevious)}">Previous Page &nbsp; </apex:outputPanel>        
                <apex:outputPanel style="color:grey;" rendered="{!NOT(acctSSC.HasNext)}">Next Page</apex:outputPanel>        
                <apex:commandLink action="{!next}" value="Next Page" rendered="{!acctSSC.HasNext}" rerender="pbAccts"/>
     
            </apex:outputPanel>
           
        </apex:pageBlock>   
       
    </apex:form>
   
</apex:page>

APEX :

/*
* Description : Controller Class for Students List Page
* Author : Rajat Mahajan
*/

public class StudentsController {

    public StudentsController (ApexPages.StandardController controller){
        pageSize = '5';
        updateStandardSetController();
    }
 
    //Page record size variable 
    public string pageSize {get;set;}
   
    //Standard Set Controller variable for taking all students records (Standard Set controllers methods will be used for working with the collection of records - like pagination)
    public ApexPages.Standardsetcontroller acctSSC {get;set;}
   
    //Constructor will set the default page size of records and also call the method to fetch records   
    public StudentsController (){
       
    }
   
    //Method to fetch records and display only page size records
    public void updateStandardSetController(){
        acctSSC = new ApexPages.Standardsetcontroller(Database.getQuerylocator([SELECT Id, name, website, phone FROM Account]));
        acctSSC.setPageSize(integer.valueOf(pageSize));
    }
   
    //Method to get all records on to the page
    public List<Account> getAccounts(){
        return acctSSC.getRecords();
    }
   
    //Method to set the number of records on the page to be displayed as per user option
    public List<SelectOption> getPageSizes(){
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('5','5'));
        options.add(new SelectOption('10','10'));
        options.add(new SelectOption('20','20'));
        options.add(new SelectOption('50','50'));
        options.add(new SelectOption('100','100'));
        return options;
    }
   
    //Returns true/false based on records present or not
    public Boolean hasNext{
        get{
            return acctSSC.getHasNext();
        }
        set;
    }

    //Returns true/false based on records present or not
    public Boolean hasPrevious{
        get{
            return acctSSC.getHasPrevious();
        }
        set;
    }

    //Returns previous page of records if present
    public void previous(){
        acctSSC.previous();
    }

    //Returns next page of records if presen
    public void next(){
        acctSSC.next();
    }
   
    public void saveAccounts(){      
       // update acctSSC;      
    }
   
}

---------------------------------
The method saveAccounts :
If i remove the comment : // update acctSSC; (I am basically trying to save the records of StandardSetcontroller

Then i get the following compile time error :
Error Error: StudentsController Compile Error: DML requires SObject or SObject list type: ApexPages.StandardSetController at line 73 column 9

Can you please help me , acctSSC is already of type StandardSetController - I may be doing some mistake.

Please let me know

Regards

Hi,

 

From my salesforce instance, I want to remove the access of deleting of records from Recycle Bin.

OR Is it possible to hide Recycle Bin link from Home page.

 

Please let me know the possible solution

 

Thanks,

Avinash

  • July 17, 2013
  • Like
  • 0