Glad you found the solution. Yes, when the collection of objects in
the grid is not uniform, you should provide the BeanModel explicitly.
On Fri, Oct 24, 2008 at 6:04 AM, tapestryphoto <[EMAIL PROTECTED]> wrote:
>
> Ok, after some experimentation I can see that I can do this by providing a
> BeanModel.
>
> p.
>
> Quoting tapestryphoto <[EMAIL PROTECTED]>:
>
>>
>> If the source for a grid is a collection which has a generic type of
>> an abstract class and the list contains concrete classes which are not
>> all of the same subclass then it throws:
>>
>> Render queue error in BeginRender[SearchByTag:grid_0.rows.gridcell]:
>> ConcreteB cannot be cast to ConcreteA
>>
>>
>> Is this a bug? It certainly seems that way to me; at the very least
>> it seems a deficiency.
>>
>> Suggestions for a workaround? (my guess is to create another class
>> which will hold all the values I want to display, then copy everything
>> from my list of abstract-derived classes into a list of this new class
>> - how incredibly ugly. Surely there must be a better way?)
>>
>> Template fragment:
>>
>> <t:grid t:source="conList">
>> </t:grid>
>>
>>
>> Code fragments:
>>
>> @Property
>> @Persist
>> private List<AbstractClass> conList;
>>
>> // this doesn't work:
>> conList = new ArrayList<AbstractClass>();
>> conList.add(new ConcreteA());
>> conList.add(new ConcreteA());
>> conList.add(new ConcreteB());
>>
>> // this does work:
>> conList = new ArrayList<AbstractClass>();
>> conList.add(new ConcreteA());
>> conList.add(new ConcreteA());
>> conList.add(new ConcreteA());
>>
>>
>>
>> public class ConcreteA extends AbstractClass
>> {
>> }
>>
>> public class ConcreteB extends AbstractClass
>> {
>> }
>>
>> public abstract class AbstractClass
>> {
>> private String a;
>> private String b;
>>
>>
>> public String getA()
>> {
>> return "I am A";
>> }
>> public void setA(String a)
>> {
>> this.a = a;
>> }
>> public String getB()
>> {
>> return "I am B";
>> }
>> public void setB(String b)
>> {
>> this.b = b;
>> }
>>
>>
>> }
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Howard M. Lewis Ship
Creator Apache Tapestry and Apache HiveMind
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]