Skip to main content
Can't figure this out, we're trying to return some information from opportunity when clicking on accounts in a visualforce page, any help would be greatly appreciated. (Ignore strangely named variables as we have only amended some previous code)

 

Here's the full error message "Error: MyController Compile Error: Illegal assignment from LIST<Opportunity> to LIST<Opportunity> at line 16 column 1"

 

Here's the controller that errors:

 

public class MyController {

 

public Id selectedAccount { get; set; }

 

public List<Opportunity> contactsInformation { get; set; }

 

    public String getContactsInformation() {

 

        return null;

 

    }

 

    public List<Account> getMyAccounts() {

 

return [SELECT Id, Name, AccountNumber FROM Account ORDER BY

 

LastModifiedDate DESC LIMIT 10];

 

}

 

public void accountClicked() {

 

contactsInformation = [SELECT Name, Amount FROM Opportunity

 

WHERE AccountID = :selectedAccount];

 

}

 

}

 

And here's the Page code:

 

<apex:page controller="MyController">

 

<apex:form >

 

<apex:dataList value="{! myaccounts}" var="acct">

 

<apex:commandlink action="{! accountClicked}" rerender="ContactDetail">

 

<apex:outputText value="{! acct.name}"/>

 

<apex:param name="id" value="{! acct.Id}" assignTo="{!selectedAccount}"/>

 

</apex:commandLink>

 

</apex:dataList>

 

</apex:form>

 

<apex:outputPanel id="ContactDetail">

 

<apex:repeat value="{! contactsInformation}" var="Opportunity">

 

<p>{! Opportunity.Name & ' ' & Opportunity.Amount}</p>

 

</apex:repeat>

 

</apex:outputPanel>

 

</apex:page>
2 个回答
  1. 2013年1月23日 13:29
    Do you have any public or global class named Opportunity in your org?

     

    --KC
0/9000