Monday, October 25, 2010

how to extends class with UiBinder

hi,

I need to create a class, myBox, to extends HTMLPanel so that i can
add content to it. here is my code:

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

<g:HTMLPanel styleName="FormsBox">
<div class="FormsTop">&nbsp;</div>
<g:HTMLPanel styleName="FormsContent">
<g:HTMLPanel ui:field="_contentPanel"></g:HTMLPanel>
</g:HTMLPanel>
<div class="FormsBtm">&nbsp;</div>
</g:HTMLPanel>
</ui:UiBinder>


.java:
public class MyBox extends Composite {

/**
* The UiBinder interface.
*/
interface Binder extends UiBinder<HTMLPanel, MyBox> {
}

@UiField
HTMLPanel _contentPanel;

/**
* The UiBinder instance.
*/
private static final Binder BINDER = GWT.create(Binder.class);

public MyBox() {
HTMLPanel rootElement = BINDER.createAndBindUi(this);
this.initWidget(rootElement);

rootElement.add(_contentPanel);
}

}


Then I tried to use MyBox in another ui.xml like the below:

...
<my:MyBox ui:field="_myfield">
<h2>my box!</h2>
</my:MyBox>
...

gwt complained:
[ERROR] Unexpected text in <my:MyBox ui:field="_myfield"><h2>my box!</
h2>

anyone know how to fix this? Thanks!

--
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