You need to sign in to do that
Don't have an account?

How to display SOQL results in Visualforce page
I need to display the search results of a SOQL query in a Visualforce page. The results should be displayed in a list (e.g. 7 Contacts are returned in the search results - the list would have 7 rows). Can I do this without a controller class? I already have the search results. I do not need to run another query. I simply need a Visualforce page to display the results. If I have to use a controller class is there a way to pass the search results (i.e. list of objects) into the controller via the ApexPages.currentPage().getParameters() method or by some other means? Or is there another way to display the results without even using the Visualforce page?
Thanks!
Thanks!
To Store the results/records return by SOQL query, you will need c controller.
You can refer:
https://help.salesforce.com/HTViewSolution?id=000205631&language=en_US
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000Ag9bIAC
Thanks,
Pratik
P.S. If this answers you question, please mark it as "Best Answer" so it will help other community members too.
You need a controller class to pass values to Visualforce page. You can use a Pageblock table in the VF Page the display the list of objects.
The List<SObjects> must be defined in the controller class and the query results must be passed to this list. Using this list values, the page block table must be created in the VF page. There is no need for ApexPages.currentPage().getParameters() method.
Regards,
Abilash
It's really simple, you need to have a list<Object> defined in Apex Controller, like list<Account> accts = [select id, Name from Account limit 30] ;
and then in vf page you may use, <apex:pageBlockTable> , <apex:repeat>
<apex:pageBlockTable value="{!accts}" var="item">
<apex:column value="{!item.id}"/>
<apex:column value="{!item.name}"/>
</apex:pageBlockTable>
please mark this answer, if it resolves your query.
Thanks
Varun
List <Contact> results = ApexPages.currentPage().getParameters().get('contacts');
ApexPages.currentPage().getParameters().get('contacts'); " This returns a String and you are trying to assing it to List variable...
Is there a way to pass a list variable into the controller using the getParameter()? I don't see anything that supports this. So even though I already know the results, it sounds like I have to pass the original search parameter (i.e. a string) into the controller and do the query again. That seems like a lot of unnecessary duplicate work.
thanks
List <Contact> results =
ApexPages.currentPage().getParameters().get('contacts').split(',');
This will create you the list, along with it you may use remoting to pass in the value from Page to controller, or you may use Ajax calls..
please mark this answer as best answer if it solves your issue.