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
krishivkrishiv 

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:form>

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

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

</apex:form>

</apex:page>

 

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

hiii,

try this example

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

 

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;
}

}