How to use UIBinder with customized composite widget

553 views
Skip to first unread message

Rick

unread,
Dec 21, 2009, 6:13:55 AM12/21/09
to Google Web Toolkit, rbans...@gmail.com
Hi all

As GWT is adding widgets in Horizontal panel, in the same way I want
to get element in my composite widgets so that I can manage their
layout in onAttach means I want to get label and html in RComposite
widget's on attach.

ui.xml
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
xmlns:my='urn:import:gwt.testui.client'>

<my:RCompositeWidget>

<g:Label>My Widgets</g:Label>
<g:HTML>in a row</g:HTML>

</my:RCompositeWidget>

</ui:UiBinder>
-->RCompositeWidget
public class RCompositeWidget extends Composite {
public RCompositeWidget() {
HorizontalPanel hp = new HorizontalPanel();
initWidget(hp);
}

}

But I am getting following exception:
In com.google.gwt.uibinder.rebind.XMLElement$1@870aad, found
unexpected child "<g:Label>"

Regards

Rick

Thomas Broyer

unread,
Dec 21, 2009, 9:44:30 AM12/21/09
to Google Web Toolkit

RCompositeWidget has to implement HasWidgets if it's meant to be a
widget container, otherwise how would UiBinder add the widgets to it?
Actually, UiBinder does not know that RCompositeWidget internally uses
an HorizontalPanel.

Message has been deleted

Rick

unread,
Dec 21, 2009, 11:28:39 PM12/21/09
to Google Web Toolkit

Thanks Thomas

Widgets are now adding by implementing HasWidgets interface.

But I need to do a little more. As there are tags in DockLayoutPanel
-- <g:north>, <g:west>, in the same way, I want to create my own
customized tags like <my:left>,<my:right> etc so that I can arrange my
layout accordingly. Can it be possible. If it is, kindly let me know
as it will be a great help for me to design my UI with more
flexibility,

On Dec 21, 7:44 pm, Thomas Broyer <t.bro...@gmail.com> wrote:
> On Dec 21, 12:13 pm, Rick <rick4...@gmail.com> wrote:
>
>
>
> > Hi all
>
> > As GWT is adding widgets in Horizontal panel, in the same way I want
> > to get element in my composite widgets so that I can manage their
> > layout in onAttach means I want to get label and html in RComposite
> > widget's on attach.
>
> > ui.xml

> > <ui:UiBinderxmlns:ui='urn:ui:com.google.gwt.uibinder'


> >         xmlns:g='urn:import:com.google.gwt.user.client.ui'
> >         xmlns:my='urn:import:gwt.testui.client'>
>
> >         <my:RCompositeWidget>
>
> >         <g:Label>My Widgets</g:Label>
> >         <g:HTML>in a row</g:HTML>
>
> >         </my:RCompositeWidget>
>
> > </ui:UiBinder>
> > -->RCompositeWidget
> > public class RCompositeWidget extends Composite {
> >         public RCompositeWidget() {
> >                 HorizontalPanel hp = new HorizontalPanel();
> >                 initWidget(hp);
> >         }
>
> > }
>
> > But I am getting following exception:
> >         In com.google.gwt.uibinder.rebind.XMLElement$1@870aad, found
> > unexpected child "<g:Label>"
>
> RCompositeWidget has to implement HasWidgets if it's meant to be a
> widget container, otherwise how wouldUiBinderadd the widgets to it?

> Actually,UiBinderdoes not know that RCompositeWidget internally uses
> an HorizontalPanel.

Rick

unread,
Dec 23, 2009, 6:48:54 AM12/23/09
to Google Web Toolkit
Any idea friends???

I request from GWT members to reply this post please.

Regards

Rick

Thomas Broyer

unread,
Dec 23, 2009, 8:48:11 AM12/23/09
to Google Web Toolkit

On Dec 22, 5:28 am, Rick <rick4...@gmail.com> wrote:
> Thanks Thomas
>
> Widgets are now adding by implementing HasWidgets interface.
>
> But I need to do a little more. As there are tags in DockLayoutPanel
> -- <g:north>, <g:west>,  in the same way, I want to create my own
> customized tags like <my:left>,<my:right> etc so that I can arrange my
> layout accordingly. Can it be possible. If it is, kindly let me know
> as it will be a great help for me to design my UI with more
> flexibility,

This is planned, but not yet available (there's a TODO in the code),
unless of course you patch GWT.

Rick

unread,
Dec 23, 2009, 11:15:20 PM12/23/09
to Google Web Toolkit
Thanks Thomas

I am successful to create my customized tag by patching UIBinderWriter
-> registerParsers() method. I think GWT has done most of the work for
supporting customized tag but keeping it private.

Hans Speijer

unread,
Jan 4, 2010, 8:11:07 AM1/4/10
to Google Web Toolkit
Any news on this topic? Could you be a bit more specific on how you
patched UIBinderWriter?

On Dec 24 2009, 5:15 am, Rick <rick4...@gmail.com> wrote:
> Thanks Thomas
>

Rick

unread,
Jan 5, 2010, 12:08:09 AM1/5/10
to Google Web Toolkit
Hi

You need to write your own parser taking clue from
DockLayoutPanelParser. Then You need to register this parser in
UIBinderWriter's registerParsers() method.

Feel free if I can further help.

Thanks and regards

Rick

On Jan 4, 6:11 pm, Hans Speijer <hans.spei...@gmail.com> wrote:
> Any news on this topic? Could you be a bit more specific on how you
> patched UIBinderWriter?
>
> On Dec 24 2009, 5:15 am, Rick <rick4...@gmail.com> wrote:
>
>
>
> > Thanks Thomas
>

> > I am successful to create mycustomizedtag by patching UIBinderWriter

Reply all
Reply to author
Forward
0 new messages