+ Start a Discussion

retrieval of database records based on the value given by the user in inputText.

I tried for the above requirement in the following way ...and stuck up in the middle..... please suggest as how to move ahead...


<apex:page controller="accountcontroller">


<apex:inputText  value="{!name}"/>

<apex:commanButton value="submit" action="{!submit}"/>




public class accountcontroller()


public String name{set;get;}

public void setname(String name)


this.name = name;


public pagereference submit()


list<Account> mylist = new list<Account>();

mylist = [select name from Account where name like :name+'%'];


public accountcontroller()




anil 007anil 007


try this example

<apex:page controller="theController">
<apex:pageBlock mode="edit" id="block">
<apex:outputLabel for="searchText">Search Text</apex:outputLabel>
<apex:inputText id="searchText" value="{!searchText}"/>
<apex:commandButton value="Go!" action="{!doSearch}"
rerender="block" status="status"/>
<apex:actionStatus id="status" startText="requesting..."/>
<apex:pageBlockSection title="Results" id="results" columns="1">
<apex:pageBlockTable value="{!results}" var="l"
<apex:column value="{!l.name}"/>
<apex:column value="{!l.email}"/>
<apex:column value="{!l.phone}"/>


public class theController {
String searchText;

List<Lead> results;
public String getSearchText() {
return searchText;
public void setSearchText(String s) {
searchText = s;
public List<Lead> getResults() {
return results;
public PageReference doSearch() {
results = (List<Lead>)[FIND :searchText RETURNING Lead(Name, Email, Phone)][0];
return null;