[SalesForce] Error: Unknown property ‘SetValue.name’

I am new to salesforce tech. Help me .

As I m using both standard Controller and extension I cant get the values from custom controller(PDFGeneration). If I dont give getMethod() to return value to the page, I m getting error like,

"Cannot find ContactStandardController.name"

Can I get the value of setString in this VFpage.

Please find my code below

My Apexpage

<apex:page renderAs="PDF" standardController="Contact" extensions="PDFGeneration" recordSetVar="contacts">
<apex:outputLabel >Email Attachment pdf sent successfully</apex:outputLabel>
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!contacts}" var="i">
<apex:column headerValue="Contact Name">
<apex:outputField value="{!i.Name}"/>
</apex:column>
<apex:column headerValue="Account Name">
<apex:outputField value="{!i.Account.name}"/>
</apex:column>
</apex:pageBlockTable>

<apex:pageBlockTable value="{!setString}" var="j">

<apex:column headerValue="Id">
<apex:outputText value="{!j.name}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>

Class:

global class PDFGeneration
{

Set<String> setString;
          public PDFGeneration(ApexPages.StandardController cont) 
         { }

    public PDFGeneration(ApexPages.StandardSetController con) 
    {
        List<Candidate__c> listCandidate=[Select id, name, First_Name__c, Last_Name__c,Mobile_Number__c, E_mail__c from Candidate__c];

        setString  =new Set<String>{String.valueOf(listCandidate)};
    }

    public Set<String> getSetString()
    {
    return setString;
    }


public void generatePDF()
{
Messaging.SingleEmailMessage email=new Messaging.SingleEmailMessage();
.......
}
}

Best Answer

Your setString property returns a set of strings not a set of objects that have a name property. So your table is iterating over the strings an you can just the string value directly:

<apex:outputText value="{!j}"/>

But perhaps what you are trying to do is this:

global class PDFGeneration
      public PDFGeneration(ApexPages.StandardController sc) {
      }
      public List<Candidate__c> getSetString() {
          return [Select id, name, First_Name__c, Last_Name__c,Mobile_Number__c, E_mail__c
                  from Candidate__c];
      }
      ...
}

in which case {!j.name} would work.

Related Topic