You need to sign in to do that
Don't have an account?
daniel.duarte
Get inputField Value in Controller Extension
Hello,
I am trying to develop a page that shows the records of a custom object in a panelGrid according to a filter, where the user specifies values for the object's fields. I want to write a controller extensions that fetches the records from the Database using SOQL, but I need to get the values from the page, after the user types it. It probably will be something like [select field1, field2 from customobject__c where field1 = :ApexPages.currentPage().... (i don't know the rest)]
Thanks
You need a property similar to this in your controller extension:
And you can query on it using SOQL as you might expect:
In your VisualForce page, then you only need to do this to connect the input to your controller:
The apex:inputText element will update the value of myFilter in your controller automatically, whenever the form is submitted (i.e. any action is taken). That's why VisualForce and Apex are great... it's easy to connect your UI to your data.
All Answers
You need a property similar to this in your controller extension:
And you can query on it using SOQL as you might expect:
In your VisualForce page, then you only need to do this to connect the input to your controller:
The apex:inputText element will update the value of myFilter in your controller automatically, whenever the form is submitted (i.e. any action is taken). That's why VisualForce and Apex are great... it's easy to connect your UI to your data.
Thanks a lot.
I also found a way of using inputField instead of inputText, because I have some picklist fields and relationship that I don't want the user to type a value, I want the user to select one of the options.
In the controller:
In the page: