1

Page:

<apex:page showHeader="true" sidebar="true" controller="ComposeEmailController">
<apex:stylesheet value="{!URLFOR($Resource.bootstrap, 'sf-bootstrap/css/bootstrap.min.css')}"/>
<apex:includeScript value="{!URLFOR($Resource.bootstrap, 'sf-bootstrap/js/bootstrap.min.js')}"/>

<apex:form styleClass="form-horizontal">
    <div class="form-group">
        <apex:selectList value="{!fromAddresses}" multiselect="false">
        </apex:selectList>
    </div>
</apex:form>

Controller:

public class ComposeEmailController {

String fromAddress{get; set;}
Case memberCase {get; set;}
Account account {get; set;}
Contact contact {get; set;}
public List<From_Email_Address__c> fromAddresses;


    public ComposeEmailController() {
        fromAddresses = [Select Id, Name, From_Address__c FROM From_Email_Address__c ORDER BY Name];
    }
}

Error:

Unknown property 'ComposeEmailController.fromAddresses' (Line: 1, Column: -1)

3
  • have a get;set; for fromAddresses
    – Prady
    Commented Mar 1, 2016 at 18:51
  • I tried that and am still getting the same error Commented Mar 1, 2016 at 18:51
  • Thats really strange.
    – Prady
    Commented Mar 1, 2016 at 18:57

3 Answers 3

2

You are getting this error because:

  • You have not defined property named fromAddresses in Controller
  • The property is not public
  • you have not defined {get; set;}
4
  • I've added get and set and am still receiving the error Commented Mar 1, 2016 at 18:57
  • Can you post the updated code?
    – Prady
    Commented Mar 1, 2016 at 18:59
  • Found the issue. The list needs to be of type string not sObject Commented Mar 1, 2016 at 19:03
  • Good, that you got it resolved.
    – Prady
    Commented Mar 1, 2016 at 19:05
2

In addition to @prady answer, there's another insidious reason you can get an Unknown Property error on a Visualforce page (although not applicable to OP) and I'm adding it here for posterity

Controller

public class MyController {
  public String foo {get; private set;}
}

VF Page MyVfPage

<apex:page controller='MyController">

    ..some markup1..

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

    .. some markup2...

<apex:page>
  • where some markup1 includes another <apex:page>
  • where some markup2 includes a </apex:page>
  • yields Unknown property foo in MyVfPage

That is, your reference to the controller property is contained inside an inner apex:page. Because the inner apex:page is not bound to a controller, the VF compiler can't find the property. Of course, you shouldn't be using nested apex:pages anyway so this is most likely a self-inflicted wound when you meant to use apex:pageBlock

0

Found the issue

public List<From_Email_Address__c> fromAddresses;

This must be of type string not From_Email_Address__c

Updated controller:

public class ComposeEmailController {

String fromAddress{get; set;}
Case memberCase {get; set;}
Account account {get; set;}
Contact contact {get; set;}
public List<String> fromAddresses {get; set;}
private Map<String, String> fromAddressesMap;


    public ComposeEmailController() {
        List<From_Email_Address__c> addresses = [Select Id, Name, From_Address__c FROM From_Email_Address__c ORDER BY Name];
        System.debug('I have this many addresses: ' + addresses.size());
        fromAddresses = new List<String>();
        fromAddressesMap = new Map<String, String>();
        for(From_Email_Address__c email : addresses){
            fromAddresses.add(email.Name);
            fromAddressesMap.put(email.Name, email.From_Address__c);
        }
    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .