Inside Tridion 2013-SP1 with DD4T template 2.0.8
I have a Schema with one Field: Foobar of Type Component Link
- Allow Multiple Values
- Allowed Schemas {Foo, Bar}
Within Java DD4T 2.0.4
created a ViewModel
@ViewModel(viewModelNames = {"foobar"}, rootElementNames = {"foobarSchema"})
public class Foobar extends TridionViewModelBase {
@ViewModelProperty
private List<Component> foobar;
// Getters & Setters
}
@ViewModel(viewModelNames = {"foo"}, rootElementNames = {"fooSchema"})
public class Foo extends TridionViewModelBase {
@ViewModelProperty
private String foo;
// Getters & Setters
}
@ViewModel(viewModelNames = {"bar"}, rootElementNames = {"barSchema"})
public class Bar extends TridionViewModelBase {
@ViewModelProperty
private double bar;
// Getters & Setters
}
What i tried is to make a interface that both classes {Foo, Bar} uses and used that interface inside Foobar List<Interface>
. This resulted into the same effect the above example. Containing only ComponentImp.
Creating a abstract class that extended the TridionViewModelBase and both Foo and Bar extended the abstract class resulted into serialize exception.
@ViewModel(viewModelNames = {"foobar"}, rootElementNames = {"foobarSchema"})
public class Foobar extends TridionViewModelBase {
@ViewModelProperty
private List<FooBarItem> foobar;
// Getters & Setters
}
public abstract class FooBarItem extends TridionViewModelBase {
@ViewModelProperty
private String sharedFooBar;
// Getters & Setters
}
@ViewModel(viewModelNames = {"foo"}, rootElementNames = {"fooSchema"})
public class Foo extends FooBarItem {
@ViewModelProperty
private String foo;
// Getters & Setters
}
@ViewModel(viewModelNames = {"bar"}, rootElementNames = {"barSchema"})
public class Bar extends FooBarItem {
@ViewModelProperty
private double bar;
// Getters & Setters
}
My question is how to make the list strongly typte with only the two Schemas/Classes Foo and Bar?
To make rendering inside JSP more straight forward.