You need to sign in to do that
Don't have an account?
Akshay Koparde
Not able to find out logical error in apex class
Hi All,
I am pretty new to salesforce. I have written a custom apex class to get the string data from visualforce page. This string is compared with records in database and displays on the screen. In my case I am performing this operation on Account object. I dont know why when I type input string(say industry type) in the input box created using Visualforce page and hit "Go!" button the list of records dont populate in the table declared in visualforce code. Kindly suggest the changes needed.
VisualForce Code
Custom controller
I am pretty new to salesforce. I have written a custom apex class to get the string data from visualforce page. This string is compared with records in database and displays on the screen. In my case I am performing this operation on Account object. I dont know why when I type input string(say industry type) in the input box created using Visualforce page and hit "Go!" button the list of records dont populate in the table declared in visualforce code. Kindly suggest the changes needed.
VisualForce Code
<apex:page controller="search_accounts" > <apex:form > <apex:pageBlock title="Account Search"> <apex:inputText value="{!input_text}" /> <apex:commandButton value="Go!"/> <apex:pageBlockTable value="{!search_result}" var="a"> <apex:column value="{!a.Name}"/> <apex:column value="{!a.Type}"/> <apex:column value="{!a.Industry}"/> <apex:column value="{!a.Phone}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
Custom controller
public class search_accounts { public string input_text; public list<Account> search_result; public string getinput_text() { return input_text; } public list<Account> getsearch_result() { return search_result; } public void setinput_text(string s) { input_text=s; } public PageReference Go() { search_result=[select Name, Type, Industry, Phone from Account Where Industry=:input_text]; return NULL; } }
try below code
thanks
let me inform if it helps you and mark it best answer if it helps you so it make proper solution for others
All Answers
try below code
thanks
let me inform if it helps you and mark it best answer if it helps you so it make proper solution for others