Crosstalk of uifields when extending widgets built with UIBinder

873 views
Skip to first unread message

Blessed Geek

unread,
Apr 5, 2010, 10:48:02 PM4/5/10
to Google Web Toolkit
Two classes are built with UIBinder, DialogPanel and WhateverPanel.
WhateverPanel extends DialogPanel.

The problem is that GWT compiler complains that it cannot find
DialogPanel's uibinder fields in WhateverPanel's ui.xml, but the
fields are not used or exposed to WhateverPanel. That is, uibinder
wants the extension class to define the uifields found in the parent
class.

Is there a UIBinder directive/annotation to tell uibinder not to do
that?
What should I do to eliminate the crosstalk during compilation (short
of advising me not to use uibinder)?

The tiring details:
============
I have a DialogPanel whose code I gleefully stole from DialogBox.java,
because I needed my own caption with a close X button.

As with DialogBox, DialogPanel extends DecoratedPanel.
The caption is defined using UIBinder:

[code file="DialogPanel-Caption.ui.xml"]
....
<g:HTMLPanel ui:field="captionPanel" height="1.4em">
<g:Label ui:field='closer' addStyleNames='{style.closer}'>X</
g:Label>
<g:HTML ui:field="captionTitle"
addStyleNames='{style.caption}'>Login</g:HTML>
</g:HTMLPanel>
....
[/code]

Now, the interesting part of the problem.
I extended DialogPanel into WhateverPanel, to define a confirmation
button as its widget using UIBinder:

[code file="WhateverPanel-Confirm.ui.xml"]
<g:LazyPanel ui:field="confirmPanel">
<g:HTMLPanel>
<g:Label ui:field="confirmMsg"/>
<br/>
<br/>
<g:Button ui:field="confirmButton">Proceed</g:Button>
</g:HTMLPanel>
</g:LazyPanel>
....
[/code]

The problem:
=========
GWT compilation complains that WhateverPanel#captionPanel is not found
as a field attribute in WhateverPanel-Confirm.ui.xml. But captionPanel
is not exposed or used outside of DialogPanel.


[code file="DialogPanel.java"]
public class DialogPanel
extends DecoratedPopupPanel
implements MouseListener
{
@UiTemplate("DialogPanel-Caption.ui.xml")
interface UIDialogBoxUiBinder
extends UiBinder<Widget, DialogPanel>{}
private static UIDialogBoxUiBinder captionUiBinder =
GWT.create(UIDialogBoxUiBinder.class);
@UiField HTMLPanel captionPanel;
@UiField HTML captionTitle;
@UiField Label closer;

public DialogPanel(boolean autoHide, boolean modal) {
super(autoHide, modal);
captionUiBinder.createAndBindUi(this);
Element td01 = getCellElement(0, 1);
DOM.appendChild(td01, this.captionPanel.getElement());
adopt(this.captionPanel);
.....
}
....
[/code]


[code file="WhateverPanel.java"]
....
@UiTemplate("WhateverPanel-Confirm.ui.xml")
interface ConfirmUiBinder
extends UiBinder<Widget, WhateverPanel> {}
private static ConfirmUiBinder confirmUiBinder =
GWT.create(ConfirmUiBinder.class);
@UiField LazyPanel confirmPanel;
@UiField Label confirmMsg;
@UiField Button confirmButton;
....
public void confirm(String title, String text){
this.confirmPanel.setVisible(true);
this.confirmMsg.setText(text);
this.setWidget(this.confirmPanel);
....
[/code]

Blessed Geek

unread,
Apr 6, 2010, 6:47:08 AM4/6/10
to Google Web Toolkit
There was an error in transcribing the code to the forum window.
Lazypanel should not be there.
So here's the problem again with the ui xml corrected.

[code file="WhateverPanel-Confirm.ui.xml"]
<g:HTMLPanel ui:field="confirmPanel">


<g:Label ui:field="confirmMsg"/>
<br/>
<br/>
<g:Button ui:field="confirmButton">Proceed</g:Button>
</g:HTMLPanel>

....
[/code]

I circumvented the problem by extracting confirmPanel into its own
class.
Which means that you cannot apply uibinder to an extension class which
itself is built with uibinder,
except when the uibinder definition of the extension class overrides
that of the parent class'.

I would like the idea that uibinder be enhanced to allow a class to
use more than one ui xml, where the ui definitions do not have any
commonality in uifields.

Reply all
Reply to author
Forward
0 new messages