Skip to main content
edited body
Source Link

Vfpage code: <apex:page controller="DocumentsSearchController" tabStyle="Documents__c" showHeader="false" sidebar="false"> <apex:form id="theForm"> <apex:sectionHeader title="Documents" /> <apex:pageBlock id="block"> <apex:outputLabel for="searchText">Search Text : </apex:outputLabel> <apex:panelGroup > <apex:inputText id="searchText" value="{!searchText}"/> <apex:commandButton value="Go" action="{!search}" rerender="theForm" status="status"/> </apex:panelGroup>

<apex:actionStatus id="status" startText="requesting..."/> <apex:pageBlockSection title="Results" id="results" columns="1" > <apex:pageBlockTable value="{!documentList}" var="doc" id="thePageBlockTabele"> <apex:column headerValue="Action"> <apex:commandLink value="View" action="/{!doc.id}"/> </apex:column> <apex:column value="{!doc.Name}"/> <apex:column value="{!doc.Description__c}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

contoroller:

public with sharing class DocumentsSearchController { //private ApexPages.StandardController controller {get; set;} public List<Documents__c> documentList {get;set;} public string searchText {get;set;} public Boolean ShowPgTable{set;get;}

public DocumentsSearchController ()
  {
    documentList = new List<Documents__c>();
    if(documentList.isEmpty())
      search();
  }

// fired when the search button is clicked
public PageReference search() {
String qry = 'select id, Name, Description__c  from Documents__c ';
if(searchText!=null )
  qry += ' where Name LIKE \'%'+searchText +'%\' order by Name ';
qry+='LIMIT 1000';
documentList = Database.query(qry);
System.debug(qry);
System.debug(documentList.size());
ShowPgTable=(!documentList.isEmpty());
return null;

}

}

vf page

apex:page controller="DocumentsSearchController" tabStyle="Documents__c" showHeader="false" sidebar="false">

apex:form id="theForm">

<apex:sectionHeader title="Documents" />

<apex:pageBlock id="block">

  apex:outputLabel for="searchText"><B>Search Text :  </b></apex:outputLabel>
    <apex:panelGroup >
      <apex:inputText id="searchText" value="{!searchText}"/>
      <apex:commandButton value="Go" action="{!search}" rerender="theForm" status="status"/>
    </apex:panelGroup>
  <br/><br/>
  <apex:actionStatus id="status" startText="requesting..."/>
  <apex:pageBlockSection title="Results" id="results" columns="1" >
    <apex:pageBlockTable value="{!documentList}" var="doc" id="thePageBlockTabele">
      <apex:column headerValue="Action">
        <apex:commandLink value="View" action="/{!doc.id}"/>
      </apex:column>
      <apex:column value="{!doc.Name}"/> 
      <apex:column value="{!doc.Description__c}"/> 
    </apex:pageBlockTable>
  </apex:pageBlockSection>
</apex:pageBlock>

</apex:form> </apex:page>

and the 2points above mentioned are solved and working fine.

Vfpage code: <apex:page controller="DocumentsSearchController" tabStyle="Documents__c" showHeader="false" sidebar="false"> <apex:form id="theForm"> <apex:sectionHeader title="Documents" /> <apex:pageBlock id="block"> <apex:outputLabel for="searchText">Search Text : </apex:outputLabel> <apex:panelGroup > <apex:inputText id="searchText" value="{!searchText}"/> <apex:commandButton value="Go" action="{!search}" rerender="theForm" status="status"/> </apex:panelGroup>

<apex:actionStatus id="status" startText="requesting..."/> <apex:pageBlockSection title="Results" id="results" columns="1" > <apex:pageBlockTable value="{!documentList}" var="doc" id="thePageBlockTabele"> <apex:column headerValue="Action"> <apex:commandLink value="View" action="/{!doc.id}"/> </apex:column> <apex:column value="{!doc.Name}"/> <apex:column value="{!doc.Description__c}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

contoroller:

public with sharing class DocumentsSearchController { //private ApexPages.StandardController controller {get; set;} public List<Documents__c> documentList {get;set;} public string searchText {get;set;} public Boolean ShowPgTable{set;get;}

public DocumentsSearchController ()
  {
    documentList = new List<Documents__c>();
    if(documentList.isEmpty())
      search();
  }

// fired when the search button is clicked
public PageReference search() {
String qry = 'select id, Name, Description__c  from Documents__c ';
if(searchText!=null )
  qry += ' where Name LIKE \'%'+searchText +'%\' order by Name ';
qry+='LIMIT 1000';
documentList = Database.query(qry);
System.debug(qry);
System.debug(documentList.size());
ShowPgTable=(!documentList.isEmpty());
return null;

}

}

and the 2points above mentioned are solved and working fine.

contoroller:

public with sharing class DocumentsSearchController { //private ApexPages.StandardController controller {get; set;} public List<Documents__c> documentList {get;set;} public string searchText {get;set;} public Boolean ShowPgTable{set;get;}

public DocumentsSearchController ()
  {
    documentList = new List<Documents__c>();
    if(documentList.isEmpty())
      search();
  }

// fired when the search button is clicked
public PageReference search() {
String qry = 'select id, Name, Description__c  from Documents__c ';
if(searchText!=null )
  qry += ' where Name LIKE \'%'+searchText +'%\' order by Name ';
qry+='LIMIT 1000';
documentList = Database.query(qry);
System.debug(qry);
System.debug(documentList.size());
ShowPgTable=(!documentList.isEmpty());
return null;

}

}

vf page

apex:page controller="DocumentsSearchController" tabStyle="Documents__c" showHeader="false" sidebar="false">

apex:form id="theForm">

<apex:sectionHeader title="Documents" />

<apex:pageBlock id="block">

  apex:outputLabel for="searchText"><B>Search Text :  </b></apex:outputLabel>
    <apex:panelGroup >
      <apex:inputText id="searchText" value="{!searchText}"/>
      <apex:commandButton value="Go" action="{!search}" rerender="theForm" status="status"/>
    </apex:panelGroup>
  <br/><br/>
  <apex:actionStatus id="status" startText="requesting..."/>
  <apex:pageBlockSection title="Results" id="results" columns="1" >
    <apex:pageBlockTable value="{!documentList}" var="doc" id="thePageBlockTabele">
      <apex:column headerValue="Action">
        <apex:commandLink value="View" action="/{!doc.id}"/>
      </apex:column>
      <apex:column value="{!doc.Name}"/> 
      <apex:column value="{!doc.Description__c}"/> 
    </apex:pageBlockTable>
  </apex:pageBlockSection>
</apex:pageBlock>

</apex:form> </apex:page>

and the 2points above mentioned are solved and working fine.

Source Link

Vfpage code: <apex:page controller="DocumentsSearchController" tabStyle="Documents__c" showHeader="false" sidebar="false"> <apex:form id="theForm"> <apex:sectionHeader title="Documents" /> <apex:pageBlock id="block"> <apex:outputLabel for="searchText">Search Text : </apex:outputLabel> <apex:panelGroup > <apex:inputText id="searchText" value="{!searchText}"/> <apex:commandButton value="Go" action="{!search}" rerender="theForm" status="status"/> </apex:panelGroup>

<apex:actionStatus id="status" startText="requesting..."/> <apex:pageBlockSection title="Results" id="results" columns="1" > <apex:pageBlockTable value="{!documentList}" var="doc" id="thePageBlockTabele"> <apex:column headerValue="Action"> <apex:commandLink value="View" action="/{!doc.id}"/> </apex:column> <apex:column value="{!doc.Name}"/> <apex:column value="{!doc.Description__c}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

contoroller:

public with sharing class DocumentsSearchController { //private ApexPages.StandardController controller {get; set;} public List<Documents__c> documentList {get;set;} public string searchText {get;set;} public Boolean ShowPgTable{set;get;}

public DocumentsSearchController ()
  {
    documentList = new List<Documents__c>();
    if(documentList.isEmpty())
      search();
  }

// fired when the search button is clicked
public PageReference search() {
String qry = 'select id, Name, Description__c  from Documents__c ';
if(searchText!=null )
  qry += ' where Name LIKE \'%'+searchText +'%\' order by Name ';
qry+='LIMIT 1000';
documentList = Database.query(qry);
System.debug(qry);
System.debug(documentList.size());
ShowPgTable=(!documentList.isEmpty());
return null;

}

}

and the 2points above mentioned are solved and working fine.