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
TheCustomCloudTheCustomCloud 

Compiler Error? Wrapper classes with Lists

I believe I may have found a compiler issue.  Anyone else run into the following:

 

I have one wrapper class called anObject.

I have a second wrapper class that contains the fields for each anObject wrapper.

 

    
    public class anObject{
        public Boolean isMaster { get; set; }
        public Id sId           { get; set; }
        public aField[] fields  { get; set; }
        
        public anObject(Id i, aField[] fl, Boolean m){
            fields = fl;
            isMaster = m;
            sId = i;
        }
    }
    public class aField{
        public Boolean checked  { get; set; } // this is the problem variable
        public String value     { get; set; }
        public String apiName   { get; set; }
        
        public aField(String v, String a){
            this.checked = true;
            this.value = v;
            this.apiName = a;
        }
    }

 

I translate the sObject into my custom anObject and put them into a list.

 

public List<anObject> theObjects    { get; set; }

 

The problem comes when I call the list in a VF page.

 

    <apex:repeat value="{!theObjects}" var="a">
        {!a.isMaster}<br/>
        <apex:repeat value="{!a.fields}" var="f">
            <input type="radio" name="{!f.apiName}" value="{!f.checked}"/>
            {!f.value} <br/>
        </apex:repeat>
    </apex:repeat>

 

Everything works except for the Boolean variable "checked".  It throws me the following error:

 

Error: /apex/SMLeadMerge: Cannot coerce from class core.apexpages.el.adapters.RuntimeTypeMetadataELAdapter to class java.lang.Boolean

 

 

 

Interesting additional note, if I do the exact same thing but instead of using a list I use a map then the boolean works fine.  

 

Mitesh SuraMitesh Sura
Hi Redfin,

Did you find the issue? For me list works, but when I replace with map, it gives "Coerce" error. Intrestingly, same logic works just fine on other page.