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
k sfdck sfdc 

URGENT:how to display my text area field value as start2characters..searchtext..end2characters?

Hi,

Suppose i will go and search fields of description value as like "name"(ORIGINALTEXTDescription value is:Himynameisrajesh).I want display with in the table column value as  " hi..name......sh " .HOW?

page:
-------
<apex:page controller="Mycontroller">

<apex:form>
<apex:commandButton value="Search" action="{!Search}"
<table width="100%" align="center">
    
         <tr>
             
                                           
                <td>
                    <apex:inputField value="{!Object.Name}"/>
                </td>
               
               <td>
                    <apex:inputField value="{!Object.Description}"/>
               </td>
         </tr>
</table>

<apex:outputpanel rendered="{!isBoolean}" id="results">
<table width="100%" align="left">
  <tr>
  <th>Name</th>&nbsp;&nbsp;&nbsp;
   <th>Description</th>

  </tr>

  </tr>
     <apex:repeat value="{!listRecords}" var="lr">
           <tr>
  <td>{!lr.wrapmyobjectSave.Name}</td>
   <td>{!lr.wrapmyobjectSave.Description__C}</td>

  </tr>

</table>


</apex:outputpanel>

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

Controller:
--------------

public class Mycontroller
{
  public Myobject__c Object{get; set;}

public Boolean isBoolean{get;set;}

public ApexPages.StandardSetController con {
        get {
                if(con == null) {
              
                    con = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Id,Name,Description__C FROM Myobject__C]));
                                      
                }
                return con;
        }
        set;
    }

public List<SearchWrapper> getlistRecords(){
     
      List<SearchWrapper> SearchWrapperlist = new List<SearchWrapper>();
       
  
        for(Sobject iterateObject : con.getRecords())
        {
        
      String s1 = String.valueOf(iteraeObject.get('Description__c'));
       
     
      String strdescription = '';
          strdescription = s1.substring(ss.IndexOf(Object.Description__c)-5,s1.IndexOf(Object.Description__c)-2);
     
       strdescription = '';
          strdescription += '...';
         
         
       strdescription = '';
           strdescription += Object.Description__c;
          
          
       strdescription = '';
           strdescription += '...';
         
          
       strdescription = '';
           strdescription += s1.substring(ss.IndexOf(Object.Description__c)+3 , s1.IndexOf(Object.Legal_Description__c)+5);
     
      System.debug('****strdescription*****'+strdescription);
                 
           SearchWrapperlist .add(new SearchWrapper((Myobject__C)iterateObject,strdescription));
        }
        return SearchWrapperlist;
    }
   

public pageReference Search()
{

isBoolean=true;
  strQuery = 'SELECT Id,Name,Description__C FROM Myobject__C';
  if( Object.Name !=NULL || Object.Description__C != NULL)
  {
    strQuery += 'WHERE ';

  }
  if(Object.Name != NULL){
            strQuery += 'Name =\'' + Object.Name + '\' AND ' ;
        }
     
        if(Object.Description__C != NULL){
            strQuery += 'Description__C  LIKE \'%'+Object.Description__C +'%\' AND' ;
        }

}


strQuery = strQuery.substring(0, strQuery.length()-4);
  con = new ApexPages.StandardSetController(Database.getQueryLocator(strQuery));

                 

}

public class SearchWrapper
     {
       public Myobject__C wrapmyobjectSave{get; set;}
      
       public String strdescription{get; set;}
      
       public SearchWrapper(Myobject__c wrapDropboxPDFSave, String strdescription)
       {
         this.wrapmyobjectSave=wrapmyobjectSave;
         this.strdescription=strdescription;      
       }
           
     }
    
NOTE:Suppose i will go and search fields of description as like "name"(ORIGINALTEXT:Himynameisrajesh).I want display with in the table column value as  " hi..name......sh " .HOW?
please help me...........

ERROR:strlegaldescription = ss.substring(ss.IndexOf(Object.Description__c)-4,ss.IndexOf(Object.Description__c)-1);
                strdescription += s1.substring(ss.IndexOf(Object.Description__c)+3 , s1.IndexOf(Object.Legal_Description__c)+5);

please help me...........
RamuRamu (Salesforce Developers) 
Can you please elaborate your requirement probably with an image if possible just for better understanding?