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
DupeNukemDupeNukem 

Help displaying SOQL/SOSL Results in Visualforce?

I'm new to Visualforce and Apex, and I'd appreciate any help on my problem...

Basically, I have a new Visualforce page that I created (let's call it "OppAnalysis").  The page gets passed a query string parameter based on the Account Name / Account ID.  (This page launches from a custom link on the Account Record.)

What I'd like to do is create a defined set of queries in Apex  (maybe 15 queries in all) and then have those queries generate lists/arrays on the fly, using the current Account Name / Account ID as a "key" (when the Visualforce page is loaded).  Each query would generate a list/array of data.  I want that information to display on the Visualforce page in the specific sections I define (either under a PageBlock or in a PageBlockTable / PageBlockDataTable).

So far I've been able to get the page to display simple Account information and a related list of all Opportunities with no problem, but I really only want to display Opportunities that meet certain criteria.

1) Is this possible?
2) If so, can you provide any sample code for displaying a query result in visualforce (specifically as it relates to a list/array). 

THANKS!
David VPDavid VP
Straight from the docs (section : building custom controllers) :

Code:
public class opportunityList2Con {
    public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator([select name,closedate from Opportunity]));
            }
            return setCon;
        }
        set;
    }
    public List<Opportunity> getOpportunities() {
         return (List<Opportunity>) setCon.getRecords();
    }
}

<apex:page controller="opportunityList2Con">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!opportunities}" var="o">
            <apex:column value="{!o.name}"/>
            <apex:column value="{!o.closedate}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

 


-David
DupeNukemDupeNukem
Thanks -- much appreciated!