>
> ParentComponent class has
> @UiChild(tagname="ChildComponent")
> public void add(ChildComponent c) {}
>
> If the UiBinder has
> <g:HTMLPanel>
> <aj:ChildComponent ui:field="child1"></aj:ChildComponent>
>
> Then it works
>
> But if I have
> <g:HTMLPanel>
> <aj:ParentComponent ui:field="parent1">
> <aj:ChildComponent ui:field="child1"></aj:ChildComponent>
> </aj:ParentComponent>
>
> Then I get a compoile error MyTest.ui.xml has no ui:field attribute for
> <package>.MyTest#child1
>
> Any ideas? I'm stumped.
>
In your example you have named your custom @UiChild tag the same as one of
your components (ChildComponent). Now things might be ambiguous as
<aj:ParentComponent ui:field="parent1">
<aj:ChildComponent></aj:ChildComponent>
</aj:ParentComponent>
can now mean "call method annotated with @UiChild(tagname=ChildComponent)"
or "add ChildComponent to ParentComponent". Looks like GWT gives @UiChild
higher priority and thats why you get an error if you try to assign a
ui:field to it. GWT thinks you are trying to assign ui:field to a @UiChild
method call which does not work.
When you use @UiChild then your UiBinder file look like:
<my:CustomComponent>
<my:leftaligned> <!-- all lower case, so it never clashes with possible
class names of other widgets -->
<g:FlowPanel ui:field="child1" />
</my:leftaligned>
</my:CustomComponent>
class CustomComponent {
@UiChild // by default GWT strips off the "add" prefix and uses
lowercase(LeftAligned) as tag name
void addLeftAligned(Widget w) {
HasWidgets leftWidgets = getLeftContainer();
leftWidgets.add(w);
}
}
-- J.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.