+ Start a Discussion

search button isnt working well

hi friends
this is the controller code:
public class NewAndExistingController {

    public Customer__c customer{ get; private set; }

    public NewAndExistingController() {
        Id id = ApexPages.currentPage().getParameters().get('id');
        customer= (id == null) ? new Customer__c() :
            [SELECT Name, address__c, full_name__c FROM Customer__c WHERE Id = :id];
     public String idNumber{
        // *** setter is NOT being called ***
        set {
            idNumber= value;
     public Customer__c getCustomer() {
        return customer;
     public PageReference getCustomer1() {
            [SELECT Name, address__c, full_name__c FROM Customer__c WHERE Name = :idNumber];
             customer=new Customer__c();
            PageReference acctPage = new ApexPages.StandardController(customer).view();
        return acctPage;
    public PageReference save() {
        try {
        } catch(System.DMLException e) {
            return null;
        //  After Save, navigate to the default view page:
        return (new ApexPages.StandardController(customer)).view();
    public PageReference getSpecificCustomer()
    PageReference pageRef = new PageReference('partialURL');
    return pageRef;
    public PageReference gotoCompetitorSearch() {
    return Page.Shop;

this is the view code
<apex:page controller="NewAndExistingController">
    <apex:form >
        <apex:pageBlock mode="edit">
            <apex:pageMessages />
            <apex:pageBlockSection >
                <apex:inputField value="{!customer.Name}"/>
                <apex:commandButton action="{!getCustomer1}" value="find">
                  <apex:param name="idNumber"
                <apex:inputField value="{!customer.address__c}" required="false"/>
                <apex:inputField value="{!customer.full_name__c}" required="false"/>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!gotoCompetitorSearch}" value="go shopping!" />

the find with getcustomer1 action isnt working.
i am a total beginner and any help will be grateful.
thanks, Liron. 
sushant sussushant sus
In the method getCustomer1 you have to get 
Id id = ApexPages.currentPage().getParameters().get('idNumber');
because you are passing this value to controller 

No I am trying to do a search button
I have a custom object named Customer__c 
it has Name - string (this is the id number of the person for me)- like "12345" for example
ans 2 custom attributes-
and full_name__c
I want to make a form with 3 input fields.
the first input field gonna be the Name- means again the id number of the person for me 
near that input field will be a button with the text find. i want to create a function in my custom controller that will find the right customer by this name and if success will return to this page the customer full name and address to the 2 correct input fields. 
and if not we will see a text message you are new.
in both cases the user if new or old will be able to change his full name and address and save it and continue to the next page there its id will be sent as a parameter.

the issue is i dont have an idea how to write the find customer by Name method.
any help ? thanks again