Wednesday, September 28, 2011

Re: UiBinder using Element and appendChild(child) possible?

No need to appendChild in GlassPanel. In glassPanel constructor
specify the uiBinder.createAndBindUi(this), it binds the divelement
through UiBinder interface.

S. Abraham
www.DataStoreGwt.com
Persist objects directly in GAE

On Sep 27, 7:42 pm, "benjamin_ma...@lavabit.com"
<benjamin_ma...@lavabit.com> wrote:
> Hi,
> I wanted to create some lightweight Elements using UiBinder. I've
> created a 'root' Element called GlassPanel:
>
> (.ui.xml)
> <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
> xmlns:g="urn:import:com.google.gwt.user.client.ui">
>
>         <div ui:field="panel">
>                 <div style="someStyles..." />
>         </div>
> </ui:UiBinder>
>
> (.java)
> public class GlassPanel extends UiObject {
>         interface GlassUiBinder extends UiBinder<DivElement, GlassPanel> {}
>         private static GlassUiBinder uiBinder =
> GWT.create(GlassUiBinder.class);
>
>         @UiField DivElement panel;
>
>         public GlassPanel() {
>                 setElement(uiBinder.createAndBindUi(this));
>         }
>
> }
>
> There will now be several other Elements that should use this one as
> their 'root'. I want to do something like this:
>
> (.ui.xml)
> <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
> xmlns:g="urn:import:com.google.gwt.user.client.ui">
>
>         <e:GlassPanel>
>                 <span ui:field="messagePanel"/>
>         </e:GlassPanel>
> </ui:UiBinder>
>
> It works if I say that GlassPanel.java implements HasHTML. But then
> UiBinder uses the setHTML method which kills the inner div in my
> GlassPanel panel. Instead it would be cool if it could call
> 'appendChild()' on my GlassPanel panel and simply add the additional
> Element. Is it possible?
> Maybe somehow using @UiChild ?!
>
> I'm using Eclipse 3.7 and GWT 2.4.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment