Re: GWT 2.5 change to provided=true for HTMLPanel

1,503 views
Skip to first unread message

David Lee

unread,
Aug 19, 2012, 10:05:05 AM8/19/12
to google-we...@googlegroups.com
This works for me as long as I create the widget manually prior to calling initWidget(uiBinder.createAndBindUi(this)); 



On Sunday, July 22, 2012 2:48:13 PM UTC-4, RyanZA wrote:
Previously in GWT 2.4 and below, this would work:

UI Binder:
<g:HTMLPanel ui:field="myPanel" />

Code:
@UiField (provided=true)
    HTMLPanel myPanel;

myPanel = new HTMLPanel("foobar");


In GWT 2.5, this now gives an error:

(gwt source)
    // Make sure that, if there is a UiField for this panel, it isn't
    // (provided = true), as that isn't supported.
    if (uiField != null && uiField.isProvided()) {
      writer.die("UiField %s for HTMLPanel cannot be provided.", fieldName);
    }


Just wondering why provided=true is no longer supported? AFAIK this was the purpose of provided=true in UiBinder?

I've now changed the code to have UiBinder create an HTMLPanel for me and then add my widget to it, but this gives an extra unneeded wrapping div in my HTML...

Peter Leong

unread,
Aug 19, 2012, 9:52:46 PM8/19/12
to google-we...@googlegroups.com
I'm having same problem.  Did you find a solution?

My code uses 'IsWidget', no Composite: http://subversion.assembla.com/svn/freshcode_public/learn/gwt/src/main/java/biz/freshcode/learn/gwt/client/uispike/gxt/LineItem.java
Also, I'm using 2.5.0-rc1 because of the Maven plugin.

Pete

RyanZA

unread,
Aug 20, 2012, 9:24:16 AM8/20/12
to google-we...@googlegroups.com
It seems to be an issue with the HTMLPanel itself - it blocks @UiField (provided=true) explicitly. I still have no idea why, unfortunately.

Quickest workaround is to remove the (provided=true) part, and then make the HTMLPanel yourself explicitly, and add it to the original one.

eg in your code, change:

@UiField(provided = true)
    HTMLPanel pnlContent;
to
@UiField HTMLPanel pnlContent;
and

@Override public Widget asWidget() { lblName = new LabelToolItem(row.getStr()); pnlContent = new HTMLPanel(renderer.render(row)); return binder.createAndBindUi(this); }

to

@Override
public Widget asWidget() {
lblName = new LabelToolItem(row.getStr());
HTMLPanel pnlContent_temp = new HTMLPanel(renderer.render(row));
Widget w = binder.createAndBindUi(this);
pnlContent.add(pnlContent_temp);
return w;
}

Peter Leong

unread,
Nov 19, 2012, 9:28:53 PM11/19/12
to google-we...@googlegroups.com
Thanks Ryan.  That works.
Also, this is totally funny:
- Forget I've tried to solve this problem before
- Find my own question online
- Question is already answered
.... it's like time travel.
Reply all
Reply to author
Forward
0 new messages