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
sonamsonam 

Values not Captured from VF page

Hi,

I have to implement a search functionality where

public class mycustomcontroller
{
public List<Contact> ContactObjects {get;set;}
 
public  PageReference runSearch(){
String firstName= ContactObj.FirstName;

// code
}
}

In the VF page i have used the below to capture the firstname.

<td><apex:outputLabel >Contact First Name &nbsp;</apex:outputLabel></td>
                    <td>
                 <apex:inputField value="{!ContactObj.FirstName}" id="fname"/>    
   </td>

M not able to get the value of firsntname.Its null in the debug logs.

Please help.

Thanks in advance.
RoshRosh
What you have done is not correct.
Please modify your class:

//class
public class mycustomcontroller
{
  public Contact ContactObj {get; set;}

  public List<Contact> ContactObjects {get;set;}
  
  public mycustomcontroller() {
    ContactObj = new Contact();
  }

  public  PageReference runSearch(){
  String firstName= ContactObj.FirstName;

  // code
  }
}