function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JosephJJosephJ 

Error: action="{!refreshGrid}": Unknown method 'TaskStandardController.refreshGrid()'

I'm getting an error on the page . Also how do i include tow values in pageblocktable where one value is {!SearchResults} which i've written already and another which i need to include is {!tasks} ? I need to do pagination with this error getting solved . Experts please help . I really need it.

Thanks in advance.
James.


<apex:page controller="TaskSearchController">

     <apex:form id="searchForm">
      <apex:PageBlock mode="edit">    
    
       <apex:actionFunction action="{!refreshGrid}" name="queryByPage" reRender="myPanel,myButtons" >
       <apex:param name="firstParam" assignTo="{!selectedPage}" value="" />
       </apex:actionFunction>
     
       <apex:dynamicComponent componentValue="{!myCommandButtons}"/>       
       <apex:outputPanel id="myPanel">
       <apex:pageMessages id="theMessages" />
             <apex:pageBlockButtons >
                <apex:commandButton action="{!edit}" id="editButton" value="Edit"/>
                <apex:commandButton action="{!save}" id="saveButton" value="Save"/>
                <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>
            </apex:pageBlockButtons>

            <apex:inlineEditSupport showOnEdit="saveButton, cancelButton"
                     hideOnEdit="editButton" event="ondblclick"
                        changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
           
         <apex:pageblockSection id="searchBlockSection">
         <apex:pageBlockSectionItem id="searchBlockSectionItem">
         <apex:outputLabel >Keyword</apex:outputLabel>
                <apex:panelGroup >
                <apex:inputtext id="searchTextBox" value="{!searchText}"> </apex:inputtext>
                <apex:commandButton Id="btnSearch" action="{!Search}" rerender="renderBlock" status="status" title="Search" value="Search">                    </apex:commandButton>
            </apex:panelGroup>
         </apex:pageBlockSectionItem>
       </apex:pageblockSection>
      <apex:actionStatus id="status" startText="Searching... please wait..."/>    
     <apex:pageBlocksection id="renderBlock" >
    <apex:pageblocktable value="{!SearchResults}" var="t" rendered="{!NOT(ISNULL(SearchResults))}" align="center">

            <apex:outputLink value="/{!t.Id}">{!t.Subject}</apex:outputLink>
            <apex:column value="{!t.Subject}"/>
            <apex:outputLink value="/{!t.Id}">{!t.Status}</apex:outputLink>
            <apex:column value="{!t.Status}"/>
            <apex:facet name="footer">Showing Page # {!pageNumber} of {!totalPages}        </apex:facet>
           
      </apex:pageblocktable>   
   </apex:pageBlocksection>
   </apex:outputPanel>
   </apex:pageblock>
  </apex:form>
    <apex:enhancedlist type="Activity" height="800" rowsPerPage="50" customizable="False"/>
   </apex:page>


 
    //Apex

    public with sharing class TaskListController
    {
        private integer counter=0;  //keeps track of the offset
        private integer list_size=5; //sets the page size or number of rows
        public integer total_size; //used to show user the total size of the list
       
       
        public string selectedPage{get;set{selectedPage=value;}
    }
   
    public TaskListController() {
        total_size = [select count() from Task]; //set the total size in the constructor
        selectedPage='0';
    }
   
    public Task[] getTasks() {
               
        if (selectedPage != '0') counter = list_size*integer.valueOf(selectedPage)-list_size;
        try {
            //we have to catch query exceptions in case the list is greater than 2000 rows
                Task[] taskList = [select Id,Subject, Status, Description
                                     from Task
                                     order by Id
                                     limit :list_size
                                    offset :counter];                  
                return taskList;
       
        } catch (QueryException e) {                           
                ApexPages.addMessages(e);                  
                return null;
        }       
    }
   
    public Component.Apex.pageBlockButtons getMyCommandButtons() {
       
        //the reRender attribute is a set NOT a string
        Set<string> theSet = new Set<string>();
        theSet.add('myPanel');
        theSet.add('myButtons');
               
        integer totalPages;
        if (math.mod(total_size, list_size) > 0) {
            totalPages = total_size/list_size + 1;
        } else {
            totalPages = (total_size/list_size);
        }
       
        integer currentPage;       
        if (selectedPage == '0') {
            currentPage = counter/list_size + 1;
        } else {
            currentPage = integer.valueOf(selectedPage);
        }
    
        Component.Apex.pageBlockButtons pbButtons = new Component.Apex.pageBlockButtons();       
        pbButtons.location = 'top';
        pbButtons.id = 'myPBButtons';
       
        Component.Apex.outputPanel opPanel = new Component.Apex.outputPanel();
        opPanel.id = 'myButtons';
                               
        //the Previous button will alway be displayed
        Component.Apex.commandButton b1 = new Component.Apex.commandButton();
        b1.expressions.action = '{!Previous}';
        b1.title = 'Previous';
        b1.value = 'Previous';
        b1.expressions.disabled = '{!disablePrevious}';       
        b1.reRender = theSet;

        opPanel.childComponents.add(b1);       
                       
        for (integer i=0;i<totalPages;i++) {
            Component.Apex.commandButton btn = new Component.Apex.commandButton();
           
            if (i+1==1) {
                btn.title = 'First Page';
                btn.value = 'First Page';
                btn.rendered = true;                                       
            } else if (i+1==totalPages) {
                btn.title = 'Last Page';
                btn.value = 'Last Page';
                btn.rendered = true;                           
            } else {
                btn.title = 'Page ' + string.valueOf(i+1) + ' ';
                btn.value = ' ' + string.valueOf(i+1) + ' ';
                btn.rendered = false;            
            }
           
            if (   (i+1 <= 5 && currentPage < 5)
                || (i+1 >= totalPages-4 && currentPage > totalPages-4)
                || (i+1 >= currentPage-2 && i+1 <= currentPage+2))
            {
                btn.rendered = true;
            }
                                    
            if (i+1==currentPage) {
                btn.disabled = true;
                btn.style = 'color:blue;';
            } 
           
            btn.onclick = 'queryByPage(\''+string.valueOf(i+1)+'\');return false;';
                
            opPanel.childComponents.add(btn);
           
            if (i+1 == 1 || i+1 == totalPages-1) { //put text after page 1 and before last page
                Component.Apex.outputText text = new Component.Apex.outputText();
                text.value = '...';       
                opPanel.childComponents.add(text);
            }
            
        }
       
        //the Next button will alway be displayed
        Component.Apex.commandButton b2 = new Component.Apex.commandButton();
        b2.expressions.action = '{!Next}';
        b2.title = 'Next';
        b2.value = 'Next';
        b2.expressions.disabled = '{!disableNext}';       
        b2.reRender = theSet;
        opPanel.childComponents.add(b2);
               
        //add all buttons as children of the outputPanel               
        pbButtons.childComponents.add(opPanel); 
 
        return pbButtons;

    }   
   
    public PageReference refreshGrid() { //user clicked a page number       
        system.debug('**** ' + selectedPage);
        return null;
    }
   
    public PageReference Previous() { //user clicked previous button
        selectedPage = '0';
        counter -= list_size;
        return null;
    }

    public PageReference Next() { //user clicked next button
        selectedPage = '0';
        counter += list_size;
        return null;
    }

    public PageReference End() { //user clicked end
        selectedPage = '0';
        counter = total_size - math.mod(total_size, list_size);
        return null;
    }
   
    public Boolean getDisablePrevious() { //this will disable the previous and beginning buttons
        if (counter>0) return false; else return true;
    }

    public Boolean getDisableNext() { //this will disable the next and end buttons
        if (counter + list_size < total_size) return false; else return true;
    }

    public Integer getTotal_size() {
        return total_size;
    }
   
    public Integer getPageNumber() {
        return counter/list_size + 1;
    }

    public Integer getTotalPages() {
        if (math.mod(total_size, list_size) > 0) {
            return total_size/list_size + 1;
        } else {
            return (total_size/list_size);
        }
    }
  
  

      // Search functionality
        
       public apexpages.standardController controller{get;set;}
       public Task l;
       public List<Task> searchResults {get; set; }

      public string searchText
      {
       get
       {
         if (searchText==null) searchText = '';
         return searchText;
       }
      set;
       }

     public TaskListController(ApexPages.StandardController controller)
     {
        this.controller = controller;
        this.l = (Task) controller.getRecord();
      }

    public PageReference search()
    {
      if(SearchResults == null)
      {
        SearchResults = new List<Task>();
      }
     else
     {
        SearchResults.Clear();
     }

       String qry ='Select Id, Subject,Status from Task where Subject like \'%'+searchText+'%\' OR Status like \'%'+searchText+'%\' Order By Subject,Status';
       SearchResults = Database.query(qry);
       //System.debug(SearchResults);
       return null;
       }
    }
James LoghryJames Loghry
Your controller is wrong in Visualforce.  You are specifying "TaskSearchController" and your Apex class name is "TaskListController"
JosephJJosephJ
Oh silly ! . But i'm getting diff errors now .the recent is  Error: <apex:inlineEditSupport> can only be child of outputField or container components. This thing has taken me 3 days to do it . Could you please once try in your dev org and help me with your expertise .

Thanks !
James LoghryJames Loghry
 Not too familiar with the inlineEditSupport tag, but according to this document: https://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_inlineEditSupport.htm, the tag must be inside of one of the following:
  • <apex:dataList>
  • <apex:dataTable>
  • <apex:form>
  • <apex:outputField>
  • <apex:pageBlock>
  • <apex:pageBlockSection>
  • <apex:pageBlockTable>
  • <apex:repeat>
Your visualforce page has it sitting outside the pageBlockTable and any of the above components.
Akshay DeshmukhAkshay Deshmukh
Hi James Joseph,

i think through inline edit you want to hide/show certain buttons on your vf page.

you can do so by including "apex:inlineEditSupport" in every pageblock section.