You need to sign in to do that
Don't have an account?
how to add search button in visual force page
Hi,
I am working on visualforce page on lead object and this visualforce page will be used when user click on the "new(already exist) " button then this new VF page popup and to make sure that user not creating duplicate lead so i add field: first name,last name and email in that page.when user enter the information then userclick on "search " button and if there no lead matches with user input then he/she be able to create the new lead. i do know that how to "search button " in the vf page.
here is the VF code:
<apex:page standardController="Lead" recordSetVar="leads" sidebar="true" showHeader="true" standardStylesheets="true" tabStyle="lead" >
<style>
.activeTab {background-color: #236FBD; color:white;background-image:none}
.inactiveTab { background-color: lightgrey; color:black;background-image:none}
</style>
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Edit" action="{!save}" id="editButton" />
<apex:commandButton value="Save" action="{!save}" id="saveButton" />
<apex:commandButton action="{! cancel}" value="Cancel!" immediate="true"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Search for Duplicates" columns="1" >
<apex:inputField value="{!lead.Firstname}"/>
<apex:inputField value="{!lead.lastname}"/>
<apex:inputField value="{!lead.company}"/>
<apex:inputField value="{!lead.email}"/>
<apex:inputField value="{!lead.phone}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
please help me
thanks
You cannot get the entire thing only with a standard controller, there are multiple steps in this process.
Step 1 - Create a new class that will serve as an extension to Lead. The class should have two things - (A) a "searchText" property, that we use for the search text, and (B) a "search" method, that does the actual search. Here's what I could get :-
Step 2:- Add he controller to your page as an extension
Step 3:- Hook up the searchText and the output grid
This should give you a search box. I haven't tested the code, so you might have to fix some syntax errors etc., but this is the general direction you can take to solve this problem.
All Answers
You cannot get the entire thing only with a standard controller, there are multiple steps in this process.
Step 1 - Create a new class that will serve as an extension to Lead. The class should have two things - (A) a "searchText" property, that we use for the search text, and (B) a "search" method, that does the actual search. Here's what I could get :-
Step 2:- Add he controller to your page as an extension
Step 3:- Hook up the searchText and the output grid
This should give you a search box. I haven't tested the code, so you might have to fix some syntax errors etc., but this is the general direction you can take to solve this problem.
thanks for you help.Now i want to add "Next" button in the vf page so that it take user to next page incase there is no lead exists already to creat new lead.
thanks
Try creating Previous & Next methods in the SearchController class.
For e.g.,
Then in your code, create two links that call this method, this should give you the paging ability. Checkout http://blog.jeffdouglas.com/2009/07/14/visualforce-page-with-pagination/ for details.
In the text-box user enters the name: the code should fetch the details of that name and displayied in a Table.
-----
vF code:
--------
<apex:page sidebar="false" controller="searchcontrol1" >
<apex:form >
<apex:outputLabel style="font-weight:bold;" value="Search By Name:" ></apex:outputLabel>
<apex:inputText value="{!textData}"/>
<apex:commandButton value="Search" action="{!result}"/>
<br/> <br/>
<apex:pageBlock >
<apex:pageBlockTable value="{!bt}" var="nxt">
<apex:column value="{!nxt.name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
}
Apex Controller:
--------------------
public with sharing class searchcontrol1 {
public LIST<Bottle__c> bt { get; set; }
public PageReference result() {
List<Bottle__c> bt =[select Name from Bottle__c where Name=:textData];
return null;
}
public String textData { get; set; }
}
-------------------------------------
No Error and No Out put .please somebody help to complete this task