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

Error using inner class in component attribute

I'd like to pass an Apex class that I've defined as a public inner class to a Visualforce component. When I try to save the component, I get these errors:


Error: Unsupported type SimpleOuter.SimpleInner[] encountered.

Error: Apex class 'simpleouter.simpleinner' does not exist.


Here's my sample code:



public with sharing class SimpleOuter {
public class SimpleInner {
public String one;
public String two;

<apex:attribute name="phoneStatuses" type="SimpleOuter.SimpleInner[]" required="true"
description="The phone numbers and statuses to display." />


 Any ideas?



I hit exactly the same problem about a month ago.  I couldn't find a solution - the notation looks correct and can be used that way in Apex, but doesn't seem to work when used as an attribute.  It seems that you can use standard classes in this way (I've passed ApexPages.Action attributes) but not your custom classes.


I ended up refactoring my inner class into a top level class. 

I've hit this exact same problem. Has anyone come up with a solution other than refactoring thier classes?

I work around this by making the inner class a top level class but Salesforce support suggested this, not sure if it works and I don't have test at the moment.



Dear Chris,

This is Suresh from developer support, it's regarding your open case 03173111.

Can you please try this code

<apex:component >
   <apex:attribute type="Attributeable[]" name="TruckAttribute" description="attribute for a truck" />

public interface Attributeable {

   // empty interface to allow for using inner class as component attributes.


public class Vehicle {

   public class Truck implements Attributeable {

       public String make;



Let me know if you have any issues on this.

Thanks & Regards
Suresh Uppala
Developer Support Engineer




I ran into the same exact issue. Looks like it's time to hit up IdeaExchange.


This seems like a bug that needs to be fixed rather than an idea for a new feature.


Depends on what the documenation says. If it says ihat this should work, it's a bug. Otherwise, it's an idea.


I tested the solution provided to cmarz_1 from Salesforce support, and it works. But I must say it's a bit cumbersome.

Nikhil Bhatia 6Nikhil Bhatia 6
I would prefer better to user the generic 'Object' type and in the controller type cast it accordingly.