Skip to main content
Added Code
Source Link
anmrk
  • 813
  • 6
  • 14

I'm trying to build a VF component that references an attribute that is an instance of a child class. I have a top level class A and inner class B and C which extend class A and i am trying to pass the visualforce component instance of class B. Since only top level classes can be passed to component i have declared the attribute as of type A and i am passing instance of class b to the component. But i am getting this error "Cannot convert the value of '{!classA}' to the expected type. " My question is can we pass child instances to component.

Visualforce Component

<apex:component>component controller="ComponentController">

    <apex:attribute name="list" 
        type="SObjectWrapper[]" 
        required="true"
        assignTo="{!sobjectWrappers}"
        description="" />

      <!--Some Code-->
</apex:component>

Component Controller

public with sharing class ComponentController{
    public List<SObjectWrapper> sobjectWrappers {
        get;
        set; 
    }
}

Visualforce Page

<apex:page controller="DemoController">
    <apex:form >
        <apex:repeat value="{!mapWrapper}" var="item">
          <c:DynamicTable list="{!mapWrapper[item]}" />
        </apex:repeat>
    </apex:form>
</apex:page>

Page Controller

public with sharing class DemoController {
    
    public Map<ParentNode,List<LevelOneNode>> mapWrapper{
        get ;
        set ;
    }
  // Some Code which populates the list
}

Base Class

public abstract class SObjectWrapper implements Comparable {
    // Some Code
}

Child Class

public class ParentNode extends SObjectWrapper {
    public List<LevelOneNode> levelOneNodes {
           get;
           set;
   }
   // Some Code
}

public class LevelOneNode extends SObjectWrapper {
         // Some Code
}

Also, if i directly pass instance of an child list the code is working, so the issue seems to be coming while iterating over map.

I'm trying to build a VF component that references an attribute that is an instance of a child class. I have a top level class A and inner class B and C which extend class A and i am trying to pass the visualforce component instance of class B. Since only top level classes can be passed to component i have declared the attribute as of type A and i am passing instance of class b to the component. But i am getting this error "Cannot convert the value of '{!classA}' to the expected type. " My question is can we pass child instances to component.

Visualforce Component

<apex:component>

    <apex:attribute name="list" 
        type="SObjectWrapper[]" 
        required="true"
        description="" />

      <!--Some Code-->
</apex:component>

Visualforce Page

<apex:page controller="DemoController">
    <apex:form >
        <apex:repeat value="{!mapWrapper}" var="item">
          <c:DynamicTable list="{!mapWrapper[item]}" />
        </apex:repeat>
    </apex:form>
</apex:page>

Page Controller

public with sharing class DemoController {
    
    public Map<ParentNode,List<LevelOneNode>> mapWrapper{
        get ;
        set ;
    }
  // Some Code which populates the list
}

Base Class

public abstract class SObjectWrapper implements Comparable {
    // Some Code
}

Child Class

public class ParentNode extends SObjectWrapper {
    public List<LevelOneNode> levelOneNodes {
           get;
           set;
   }
   // Some Code
}

public class LevelOneNode extends SObjectWrapper {
         // Some Code
}

Also, if i directly pass instance of an child list the code is working, so the issue seems to be coming while iterating over map.

I'm trying to build a VF component that references an attribute that is an instance of a child class. I have a top level class A and inner class B and C which extend class A and i am trying to pass the visualforce component instance of class B. Since only top level classes can be passed to component i have declared the attribute as of type A and i am passing instance of class b to the component. But i am getting this error "Cannot convert the value of '{!classA}' to the expected type. " My question is can we pass child instances to component.

Visualforce Component

<apex:component controller="ComponentController">

    <apex:attribute name="list" 
        type="SObjectWrapper[]" 
        required="true"
        assignTo="{!sobjectWrappers}"
        description="" />

      <!--Some Code-->
</apex:component>

Component Controller

public with sharing class ComponentController{
    public List<SObjectWrapper> sobjectWrappers {
        get;
        set; 
    }
}

Visualforce Page

<apex:page controller="DemoController">
    <apex:form >
        <apex:repeat value="{!mapWrapper}" var="item">
          <c:DynamicTable list="{!mapWrapper[item]}" />
        </apex:repeat>
    </apex:form>
</apex:page>

Page Controller

public with sharing class DemoController {
    
    public Map<ParentNode,List<LevelOneNode>> mapWrapper{
        get ;
        set ;
    }
  // Some Code which populates the list
}

Base Class

public abstract class SObjectWrapper implements Comparable {
    // Some Code
}

Child Class

public class ParentNode extends SObjectWrapper {
    public List<LevelOneNode> levelOneNodes {
           get;
           set;
   }
   // Some Code
}

public class LevelOneNode extends SObjectWrapper {
         // Some Code
}

Also, if i directly pass instance of an child list the code is working, so the issue seems to be coming while iterating over map.

deleted 43 characters in body
Source Link
anmrk
  • 813
  • 6
  • 14

I'm trying to build a VF component that references an attribute that is an instance of a child class. I have a top level class A and inner class B and C which extend class A and i am trying to pass the visualforce component instance of class B. Since only top level classes can be passed to component i have declared the attribute as of type A and i am passing instance of class b to the component. But i am getting this error "Cannot convert the value of '{!classA}' to the expected type. " My question is can we pass child instances to component.

Visualforce Component

<apex:component>

    <apex:attribute name="list" 
        type="SObjectWrapper[]" 
        required="true"
        assignTo="{!sobjectWrappers}"
        description="" />

      <!--Some Code-->
</apex:component>

Visualforce Page

<apex:page controller="DemoController">
    <apex:form >
        <apex:repeat value="{!mapWrapper}" var="item">
          <c:DynamicTable list="{!mapWrapper[item]}" />
        </apex:repeat>
    </apex:form>
</apex:page>

Page Controller

public with sharing class DemoController {
    
    public Map<ParentNode,List<LevelOneNode>> mapWrapper{
        get ;
        set ;
    }
  // Some Code which populates the list
}

Base Class

public abstract class SObjectWrapper implements Comparable {
    // Some Code
}

Child Class

public class ParentNode extends SObjectWrapper {
    public List<LevelOneNode> levelOneNodes {
           get;
           set;
   }
   // Some Code
}

public class LevelOneNode extends SObjectWrapper {
         // Some Code
}

Also, if i directly pass instance of an child list the code is working, so the issue seems to be coming while iterating over map.

I'm trying to build a VF component that references an attribute that is an instance of a child class. I have a top level class A and inner class B and C which extend class A and i am trying to pass the visualforce component instance of class B. Since only top level classes can be passed to component i have declared the attribute as of type A and i am passing instance of class b to the component. But i am getting this error "Cannot convert the value of '{!classA}' to the expected type. " My question is can we pass child instances to component.

Visualforce Component

<apex:component>

    <apex:attribute name="list" 
        type="SObjectWrapper[]" 
        required="true"
        assignTo="{!sobjectWrappers}"
        description="" />

      <!--Some Code-->
</apex:component>

Visualforce Page

<apex:page controller="DemoController">
    <apex:form >
        <apex:repeat value="{!mapWrapper}" var="item">
          <c:DynamicTable list="{!mapWrapper[item]}" />
        </apex:repeat>
    </apex:form>
</apex:page>

Page Controller

public with sharing class DemoController {
    
    public Map<ParentNode,List<LevelOneNode>> mapWrapper{
        get ;
        set ;
    }
  // Some Code which populates the list
}

Base Class

public abstract class SObjectWrapper implements Comparable {
    // Some Code
}

Child Class

public class ParentNode extends SObjectWrapper {
    public List<LevelOneNode> levelOneNodes {
           get;
           set;
   }
   // Some Code
}

public class LevelOneNode extends SObjectWrapper {
         // Some Code
}

Also, if i directly pass instance of an child list the code is working, so the issue seems to be coming while iterating over map.

I'm trying to build a VF component that references an attribute that is an instance of a child class. I have a top level class A and inner class B and C which extend class A and i am trying to pass the visualforce component instance of class B. Since only top level classes can be passed to component i have declared the attribute as of type A and i am passing instance of class b to the component. But i am getting this error "Cannot convert the value of '{!classA}' to the expected type. " My question is can we pass child instances to component.

Visualforce Component

<apex:component>

    <apex:attribute name="list" 
        type="SObjectWrapper[]" 
        required="true"
        description="" />

      <!--Some Code-->
</apex:component>

Visualforce Page

<apex:page controller="DemoController">
    <apex:form >
        <apex:repeat value="{!mapWrapper}" var="item">
          <c:DynamicTable list="{!mapWrapper[item]}" />
        </apex:repeat>
    </apex:form>
</apex:page>

Page Controller

public with sharing class DemoController {
    
    public Map<ParentNode,List<LevelOneNode>> mapWrapper{
        get ;
        set ;
    }
  // Some Code which populates the list
}

Base Class

public abstract class SObjectWrapper implements Comparable {
    // Some Code
}

Child Class

public class ParentNode extends SObjectWrapper {
    public List<LevelOneNode> levelOneNodes {
           get;
           set;
   }
   // Some Code
}

public class LevelOneNode extends SObjectWrapper {
         // Some Code
}

Also, if i directly pass instance of an child list the code is working, so the issue seems to be coming while iterating over map.

added 133 characters in body
Source Link
anmrk
  • 813
  • 6
  • 14

I'm trying to build a VF component that references an attribute that is an instance of a child class. I have a top level class A and inner class B and C which extend class A and i am trying to pass the visualforce component instance of class B. Since only top level classes can be passed to component i have declared the attribute as of type A and i am passing instance of class b to the component. But i am getting this error "Cannot convert the value of '{!classA}' to the expected type. " My question is can we pass child instances to component.

Visualforce Component

<apex:component>

    <apex:attribute name="list" 
        type="SObjectWrapper[]" 
        required="true"
        assignTo="{!sobjectWrappers}"
        description="" />

      <!--Some Code-->
</apex:component>

Visualforce Page

<apex:page controller="DemoController">
    <apex:form >
        <apex:repeat value="{!mapWrapper}" var="item">
          <c:DynamicTable list="{!mapWrapper[item]}" />
        </apex:repeat>
    </apex:form>
</apex:page>

Page Controller

public with sharing class DemoController {
    
    public Map<ParentNode,List<LevelOneNode>> mapWrapper{
        get ;
        set ;
    }
  // Some Code which populates the list
}

Base Class

public abstract class SObjectWrapper implements Comparable {
    // Some Code
}

Child Class

public class ParentNode extends SObjectWrapper {
    public List<LevelOneNode> levelOneNodes {
           get;
           set;
   }
   // Some Code
}

public class LevelOneNode extends SObjectWrapper {
         // Some Code
}

Also, if i directly pass instance of an child list the code is working, so the issue seems to be coming while iterating over map.

I'm trying to build a VF component that references an attribute that is an instance of a child class. I have a top level class A and inner class B and C which extend class A and i am trying to pass the visualforce component instance of class B. Since only top level classes can be passed to component i have declared the attribute as of type A and i am passing instance of class b to the component. But i am getting this error "Cannot convert the value of '{!classA}' to the expected type. " My question is can we pass child instances to component.

Visualforce Component

<apex:component>

    <apex:attribute name="list" 
        type="SObjectWrapper[]" 
        required="true"
        assignTo="{!sobjectWrappers}"
        description="" />

      <!--Some Code-->
</apex:component>

Visualforce Page

<apex:page controller="DemoController">
    <apex:form >
        <apex:repeat value="{!mapWrapper}" var="item">
          <c:DynamicTable list="{!mapWrapper[item]}" />
        </apex:repeat>
    </apex:form>
</apex:page>

Page Controller

public with sharing class DemoController {
    
    public Map<ParentNode,List<LevelOneNode>> mapWrapper{
        get ;
        set ;
    }
  // Some Code which populates the list
}

Base Class

public abstract class SObjectWrapper implements Comparable {
    // Some Code
}

Child Class

public class ParentNode extends SObjectWrapper {
    public List<LevelOneNode> levelOneNodes {
           get;
           set;
   }
   // Some Code
}

public class LevelOneNode extends SObjectWrapper {
         // Some Code
}

I'm trying to build a VF component that references an attribute that is an instance of a child class. I have a top level class A and inner class B and C which extend class A and i am trying to pass the visualforce component instance of class B. Since only top level classes can be passed to component i have declared the attribute as of type A and i am passing instance of class b to the component. But i am getting this error "Cannot convert the value of '{!classA}' to the expected type. " My question is can we pass child instances to component.

Visualforce Component

<apex:component>

    <apex:attribute name="list" 
        type="SObjectWrapper[]" 
        required="true"
        assignTo="{!sobjectWrappers}"
        description="" />

      <!--Some Code-->
</apex:component>

Visualforce Page

<apex:page controller="DemoController">
    <apex:form >
        <apex:repeat value="{!mapWrapper}" var="item">
          <c:DynamicTable list="{!mapWrapper[item]}" />
        </apex:repeat>
    </apex:form>
</apex:page>

Page Controller

public with sharing class DemoController {
    
    public Map<ParentNode,List<LevelOneNode>> mapWrapper{
        get ;
        set ;
    }
  // Some Code which populates the list
}

Base Class

public abstract class SObjectWrapper implements Comparable {
    // Some Code
}

Child Class

public class ParentNode extends SObjectWrapper {
    public List<LevelOneNode> levelOneNodes {
           get;
           set;
   }
   // Some Code
}

public class LevelOneNode extends SObjectWrapper {
         // Some Code
}

Also, if i directly pass instance of an child list the code is working, so the issue seems to be coming while iterating over map.

Added Code
Source Link
anmrk
  • 813
  • 6
  • 14
Loading
Source Link
anmrk
  • 813
  • 6
  • 14
Loading