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
pratyusha raavipatipratyusha raavipati 

i hve created search button for account name field, results have to be displayed in the below table

Hi,
this is my code
<apex:page controller="searchaccount">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputText id="searchTextBox" value="{!searchText}">
<p> Enter Account Name</p>
</apex:inputText>
 <apex:commandButton value="search" action="{!result}"/>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockTable value="{!Account}" var="a">
<apex:column headerValue="Account Name">
<apex:inputField value="{!a.Name}"/>
 </apex:column>
 <apex:column headerValue="Account Number">
<apex:inputField value="{!a.AccountNumber}"/>
 </apex:column>
 <apex:column headerValue="Mobile">
<apex:inputField value="{!a.Phone}"/>
 </apex:column>
 <apex:column headerValue="Fax">
<apex:inputField value="{!a.Fax}"/>
 </apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
 </apex:page>


public class searchaccount{

    public String searchText {get; set;}
 
  Account acc {get;set;}
  public List<Account> lstofAccount;

Public searchaccount(){
  acc = new Account();
  lstOfAccount = new List<Account>();

}
 public pagereference Result(){
        
  List<Account> acc =[select Name from Account where Name=:Name];
return null;
}

public String Name { get; set; }
}


and i am getting error
Error: Could not resolve the entity from <apex:inputField> value binding '{!a.Fax}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.
i think my visualforce code was correct and i done mistake in apex
vijay admin 10vijay admin 10
Hi Pratyusha,

Try the below code....

public class searchaccount
{
    public List<Account> accts { get; set; }
    public String name { get; set; }
    public String accountNumber {get; set;}
    public String phone {get; set;}
    public String fax {get; set;}
    

    public searchaccount()
    {
        accts = new List<Account>();
    }

    public PageReference searchAccounts()
    {
        accts = [select Id,Name,AccountNumber,Phone,Fax from Account where Name = :name and  AccountNumber= :accountNumber and Phone= :phone and Fax= :fax];
        return null;
    }
}
sfdcMonkey.comsfdcMonkey.com
hi
i update your page and class use below code
and type any account name in search box and click on the search button
<apex:page controller="searchaccount">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputText id="searchTextBox" value="{!Name}">
<p> Enter Account Name</p>
</apex:inputText>
 <apex:commandButton value="search" action="{!result}"/>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockTable value="{! lstofAccount}" var="a">
<apex:column headerValue="Account Name">
<apex:inputField value="{!a.Name}"/>
 </apex:column>
 <apex:column headerValue="Account Number">
<apex:inputField value="{!a.AccountNumber}"/>
 </apex:column>
 <apex:column headerValue="Mobile">
<apex:inputField value="{!a.Phone}"/>
 </apex:column>
 <apex:column headerValue="Fax">
<apex:inputField value="{!a.Fax}"/>
 </apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
 </apex:page>
public class searchaccount{
    public String Name { get; set; }
    public Account acc {get;set;}
    public List<Account> lstofAccount{get;set;}
 

Public searchaccount(){
  acc = new Account();
  lstofAccount = new List<Account>();

}
 public pagereference result(){
        
  lstofAccount =[select Name,AccountNumber,Phone,Fax from Account where Name=:Name];
   return null;
}


}
Let me Please infrom if it helps you
thanks


 
sujitha Ramachandrunisujitha Ramachandruni
Hi Pratyusha

<apex:page controller="searchaccount">

    <apex:form >

    <apex:pageBlock >

    <apex:pageBlockSection >

     Name: <apex:inputText id="searchTextBox" value="{!Name}">

    </apex:inputText>

     <center>
<apex:commandButton value="search" action="{!result}"/>
</center>

    </apex:pageBlockSection>

    <apex:pageBlockSection >

    <apex:pageBlockTable value="{! lstofAccount}" var="a">

    <apex:column headerValue="Account Name" value="{!a.Name}">

     </apex:column>

     <apex:column headerValue="Account Number" value="{!a.AccountNumber}">

     </apex:column>

     <apex:column headerValue="Mobile" value="{!a.Phone}">

     </apex:column>

     <apex:column headerValue="Fax" value="{!a.Fax}">


     </apex:column>

    </apex:pageBlockTable>

    </apex:pageBlockSection>

    </apex:pageBlock>

    </apex:form>

     </apex:page>


Apex:
public class searchaccount{

        public String Name { get; set; }

        public Account acc {get;set;}

        public List<Account> lstofAccount{get;set;}

    Public searchaccount(){

      acc = new Account();

      lstofAccount = new List<Account>();

    }

     public pagereference result(){

             

      lstofAccount =[select Name,AccountNumber,Phone,Fax from Account where Name=:Name];

       return null;

    }

    }