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
magandrezmagandrez 

Unknown property 'ApexPages.StandardSetController'

Hi all,

 

I'm trying to build a dataList with data from a query with a sub-query. This is the VF markup:

 

<apex:page standardController="Application__c" extensions="getDataFinalReport" tabStyle="Application__c" >

  <apex:pageBlock title="Candidates">
  <apex:form id="theForm">
    <apex:pageBlockSection showHeader="true" title="List of Candidates" >
      <apex:dataList var="a" value="{!can}" type="1">
      <apex:outputText value="{!can.Candidate_Full_Name__c}"/>
      </apex:dataList>
    </apex:pageBlockSection>
    
  </apex:form> 
  </apex:pageBlock>

</apex:page>

 

And this is the controller extension:

 

public with sharing class getDataFinalReport {

    public getDataFinalReport(ApexPages.StandardController controller) {

    }
    
    string JobOrderId = ApexPages.currentPage().getParameters().get('id');
    
    public ApexPages.StandardSetController can {
        get {
            if(can == null) {
                can = new ApexPages.StandardSetController(Database.getQueryLocator(
                
                [SELECT 
                        (SELECT Candidate_Full_Name__c 
                         FROM Application__c)
                 FROM Job_Order t 
                 WHERE Id=:JobOrderId]));
            }
            return can;
        }
        set;
    }

    // Initialize can and return a list of records  
    
    public List<ts2__Application__c > getCandidateLines() {
         return (List<ts2__Application__c >) can.getRecords();
    }
        
    
}

 

The problem now is that, when I try to save the VF gives me the following error:

 

Error: Unknown property 'ApexPages.StandardSetController.Candidate_Full_Name__c'

 

I tried creating the get/set for Candidate_Full_Name__c but it doesn't work either , can anyone help me with this?

 

Many thanks,

 

MGA

Best Answer chosen by Admin (Salesforce Developers) 
pconpcon

You can try something along the lines of this:

 

<apex:page standardController="Application__c" extensions="getDataFinalReport" tabStyle="Application__c" >
  <apex:pageBlock title="Candidates">
  <apex:form id="theForm">
    <apex:pageBlockSection showHeader="true" title="List of Candidates" >
      <apex:dataList var="can" value="{!candidates}" type="1">
      <apex:outputText value="{!can.Candidate_Full_Name__c}"/>
      </apex:dataList>
    </apex:pageBlockSection>
  </apex:form> 
  </apex:pageBlock>
</apex:page>

 

public with sharing class getDataFinalReport {
	public List<Application__c> candidates {
		get;
		private set;
	}

	public getDataFinalReport(ApexPages.StandardController controller) {
		string JobOrderId = ApexPages.currentPage().getParameters().get('id');

		Job_Order jo = [
			select (
				select Candidate_Full_Name__c 
				from Application__c
			) from Job_Order
			where Id=:JobOrderId
		];

		candidates = jo.Application__c;
	}
}

 

You might need to rewrite the candidates = jo.Application__C line to get the applicants out.  The better way would be to figure out what the field that relates Application__c and Job_Order and do the query directly off of Application__c

All Answers

Navatar_DbSupNavatar_DbSup

Hi,

 

I think you have forgotten to mention the var value inside the outputtext instead of listvalue.

 Try the below code:

<apex:dataList var="a" value="{!can}" type="1">

     <apex:outputText value="{!a.Candidate_Full_Name__c}"/>

 </apex:dataList>

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

magandrezmagandrez

Hi Navatar_DbSup,

 

No, it didn't work, It gives me the same error.

 

I think is something related with getters/setters, but I can't come up with a solution.

 

MGA

bob_buzzardbob_buzzard

This looks a little confused to me.  "can" is an instance of a StandardSetController, but you are trying to use it as the value for a datalist component, which requires a collection (e.g. list) of data.  

 

The visualforce developer's guide has the following example, which initialises the controller but then passes the records back to the page:

 

public class opportunityList2Con {
  // ApexPages.StandardSetController must be instantiated
  // for standard list controllers
    public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                      [select name,closedate from Opportunity]));
}
            return setCon;
        }
set; }
// Initialize setCon and return a list of records public List<Opportunity> getOpportunities() { return (List<Opportunity>) setCon.getRecords(); }
}

 

pconpcon

You can try something along the lines of this:

 

<apex:page standardController="Application__c" extensions="getDataFinalReport" tabStyle="Application__c" >
  <apex:pageBlock title="Candidates">
  <apex:form id="theForm">
    <apex:pageBlockSection showHeader="true" title="List of Candidates" >
      <apex:dataList var="can" value="{!candidates}" type="1">
      <apex:outputText value="{!can.Candidate_Full_Name__c}"/>
      </apex:dataList>
    </apex:pageBlockSection>
  </apex:form> 
  </apex:pageBlock>
</apex:page>

 

public with sharing class getDataFinalReport {
	public List<Application__c> candidates {
		get;
		private set;
	}

	public getDataFinalReport(ApexPages.StandardController controller) {
		string JobOrderId = ApexPages.currentPage().getParameters().get('id');

		Job_Order jo = [
			select (
				select Candidate_Full_Name__c 
				from Application__c
			) from Job_Order
			where Id=:JobOrderId
		];

		candidates = jo.Application__c;
	}
}

 

You might need to rewrite the candidates = jo.Application__C line to get the applicants out.  The better way would be to figure out what the field that relates Application__c and Job_Order and do the query directly off of Application__c

This was selected as the best answer
Thys MichelsThys Michels

I have the following Apex method with Sub query SOQL: 

public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                    [SSELECT Contact.Id, Opportunity.Id, Contact.FirstName, Contact.LastName, Contact.Phone,Contact.Account.Name, Contact.Email,Contact.Last_Contacted__c,Contact.Membership_Type__c,Opportunity.Call_Disposition__c, Opportunity.Sales_Stage__c,Opportunity.Name, Opportunity.CloseDate, Opportunity.StageName, Opportunity.CreatedDate FROM OpportunityContactRole where Opportunity.OwnerId=:Userinfo.getUserId()]));}
         return setCon;
        }
        set;
    }

How can I access the sub query fields in my Visualforce page? Below is my Visualforce code. Is says it does not understand co.Contact or co.Opportunity. Please assist with solution.

 

<apex:page controller="SalesRepPageControllerV3" tabstyle="contact" sidebar="false" showChat="true" >
   <apex:form id="theForm">
    <apex:sectionHeader title="Sales Rep Page for {!$User.FirstName}"/>
      <apex:pageBlock id="innerblock" mode="edit"> 
         <apex:pageMessages />

        <apex:pageBlock id="innerblock">  
        <apex:pageBlockSection id="pagesection">  
            <apex:pageBlockTable value="{!ContactOpportunity}" var="co" id="pageblocktable">
              <apex:column headerValue="Created Date" value="{!co.Opportunity.CreatedDate}"/>  
              <apex:column headerValue="First Name" value="{!co.Contact.FirstName}"/>  
              <apex:column headerValue="First Name" value="{!co.Contact.LastName}"/>
              <apex:column headerValue="Phone" value="{!co.Contact.Phone}"/>
              <apex:column headerValue="Account Name" value="{!co.Contact.Account.Name}"/>
              <apex:column headerValue="Email" value="{!co.Contact.Email}"/>
              <apex:column headerValue="Last Contacted" value="{!co.Contact.Last_Contacted__c}">
              </apex:column>

                <apex:column headerValue="Membership Type" value="{!co.Contact.Membership_Type__c}"/>
                <apex:column headerValue="Call Disposition">
                    <apex:inputField value="{!co.Opportunity.Call_Disposition__c}"/>
                </apex:column>
                <apex:column headerValue="Sales Stage">
                    <apex:inputField value="{!co.Opportunity.Sales_Stage__c}"/>
                </apex:column>         
            </apex:pageBlockTable>
           </apex:pageBlockSection>

        </apex:pageBlock>
        <apex:pageBlockButtons >
           <apex:commandButton value="Save" action="{!save}" reRender="pageblocktable"/>
           <apex:commandButton value="Cancel" action="{!cancel}"  reRender="pageblocktable"/>
        </apex:pageBlockButtons>  
     </apex:pageBlock>
     <apex:panelGrid columns="2">
              <apex:commandLink action="{!previous}">Previous</apex:commandlink>
              <apex:commandLink action="{!next}">Next</apex:commandlink>
    </apex:panelGrid>
    </apex:form>   
</apex:page>