You need to sign in to do that
Don't have an account?
sahil dhatrak
I want to write an controller to search the text entered in my visual force page how should i do it
<apex:page controller="search_controller">
<apex:sectionHeader title="HomePage" subtitle="Search and History" description="Use this page to search and browse history"/>
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel value="Enter Search Text "/>
<apex:inputText />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<br> <apex:commandButton value="Search"/> </br>
<br> <apex:commandButton value="History"/> </br>
</apex:pageBlock>
</apex:form>
</apex:page>
this is the visualforce oage i created
<apex:sectionHeader title="HomePage" subtitle="Search and History" description="Use this page to search and browse history"/>
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel value="Enter Search Text "/>
<apex:inputText />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<br> <apex:commandButton value="Search"/> </br>
<br> <apex:commandButton value="History"/> </br>
</apex:pageBlock>
</apex:form>
</apex:page>
this is the visualforce oage i created
Try the below links.
http://bobbuzzard.blogspot.co.uk/2011/06/execute-custom-search-when-opening-page.html
http://blog.jeffdouglas.com/2010/07/13/building-a-dynamic-search-page-in-visualforce/
searching account record from account object
VF Page:
<apex:page controller="search_controller">
<apex:sectionHeader title="HomePage" subtitle="Search and History" description="Use this page to search and browse history"/>
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:outputLabel value="Enter Search Text "/>
<apex:inputText value="{!seachname}"/>
</apex:pageBlockSection>
<apex:pageBlockSection value="{!L}"id="seachresult" var="i">
<apex:column value="{!i.ID}"/>
<apex:column value="{!i.Number}"/>
<apex:column value="{!i.name}"/>
<apex:column value="{!i.description}"/>
</apex:pageBlockSection>
<br><apex:commandButton value="Search" rerender="searchresult"/> </br>
<br><apex:commandButton value="History"/> </br>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
Public class search_controller{
Public String seachname{get;set;}
Public List<Account> L{get;set;}
Public search_controller()
{
L=New <account>();
}
Public void search()
{
Account L=[Select ID,Number,name,description from account where name:seachname LIMIT 1];
}
}
and 2nd scenario where all the results are displayed on a visual force page
Go through the example below.
Apexclass:
public class SearchTextInVFPage{
public ApexPage vflist {get;set;}
public ApexPage vfpage {get;set;}
public string searchstring {get;set;}
public SearchTextInVFPage(){
vfpage =new ApexPage();
}
public PageReference SearchText()
{
system.debug('&&&&&&&'+searchstring );
vflist =[SELECT ApiVersion,ControllerKey,ControllerType,Description,isAvailableInTouch,IsConfirmationTokenRequired,Markup,MasterLabel,Name,NamespacePrefix from ApexPage where name=:'SearchTextInVFPage'];
system.debug('................'+ vflist);
string searchstring1=searchstring.toLowerCase();
string searchstring2=searchstring.toUpperCase();
// searchstring=searchstring.equalsIgnoreCase(searchstring);
if(vflist.Markup.contains(searchstring)==true ||vflist.Markup.contains(searchstring1)==true ||vflist.Markup.contains(searchstring2)==true)
{
system.debug('search string present in visualforce page');
}
else
system.debug('search string not there in visualforce page');
return null;
}
}
visualforce page :
<apex:page controller="SearchTextInVFPage">
<apex:form >
<apex:inputText value="{!searchstring}"/>
<apex:commandButton value="Search" action="{!SearchText}"/>
<br/>
test
</apex:form>
</apex:page>
run the vf page and check.You can modify as you like.
The content of vf page will be in Markup field.
if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
List has no rows for assignment to SObject
Error is in expression '{!SearchText}' in component <apex:commandButton> in page vfpage_search
An unexpected error has occurred. Your development organization has been notified.
Go through the example below..
<apex:page sidebar="false" showHeader="false">
<iframe src='http://www.google.com/custom' width="100%" height="100%"/>
</apex:page>
Note:IF page didnot load then on the top right there is a button.click it to allow script.
if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.