Thanks for the reply rjcarr but, perhaps I didn't ask the right
question... given the following ListEditor bits:
interface ListEditorDriver extends
SimpleBeanEditorDriver<List<AbstractAnimal>,
ListEditor<AbstractAnimal, AbstractAnimalkEditor>> {}
private ListEditor<AbstractAnimal, AbstractAnimalEditor> editor =
ListEditor.of(new AbstractAnimalSource());
private ListEditorDriver driver = GWT.<ListEditorDriver>
create(ListEditorDriver.class);
class AbstractAnimalSource extends EditorSource<AbstractAnimalEditor>
{
public AbstractAnimalSource() {}
@Override
public AbstractAnimalEditor create(int index) {
AbstractAnimalEditor abstractAnimalEditor = new
AbstractAnimalEditor();
container.insert(abstractAnimalEditor , index);
return abstractAnimalEditor ;
}
@Override
public void dispose(AbstractAnimalEditor subEditor) {
subEditor.removeFromParent();
}
@Override
public void setIndex(AbstractAnimalEditor editor, int index) {
container.insert(editor, index);
}
}
class AbstractAnimalEditor extends Composite implements
Editor<AbstractAnimal> {
TextBox name;
public AbstractAnimalEditor() {
FlowPanel fp = new FlowPanel();
initWidget(fp);
InlineLabel nameLabel = new InlineLabel("Name: ");
fp.add(nameLabel);
name = new TextBox();
fp.add(name);
}
}
Is there any way I can tell the Editor Framework that my
AbstractAnimal is either a Bird, Mammal, Fish etc...?
The Editor Framework does all the widget instantiation and setting/
getting of values there doesn't appear to be a point where I can say
"If the type is Bird use the BirdEditor, if the type is Fish use the
FishEditor"...
Cheers,
Dave
On Dec 9, 7:41 am, rjcarr <[email protected]> wrote:
> Is this a GWT question? It sounds like a generic polymorphism
> question.
>
> If the latter, you have two options. Either add wing span information
> to the parent type (Animal) or do explicit checks for Birds and then
> do a cast.
>
> Good luck!
>
> On Dec 8, 9:11 am, DaveC <[email protected]> wrote:
>
>
>
> > Hi,
>
> > What I'm trying to do is pass ListEditor a list of generic types e.g.
> > an AbstractAnimal type but what the list gets might be a Bird type, a
> > Fish type, Mammal... etc...
>
> > The problem is that that my Bird type has a property "wingSpan" which
> > the Fish type does not.. they might also share a property e.g. "name"
> > or "canFly".
>
> > The Editor complains that it "couldn't find a getter for canFly in
> > proxy type ...AbstractAnimal".
>
> > Is there any way around this?
>
> > Thanks for you help in advance.
>
> > Cheers,
> > Dave
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.