On 25 oct, 19:41, mars <[email protected]> wrote:
> 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"> </div>
> <g:HTMLPanel styleName="FormsContent">
Why are you using an HTMLPanel if you're not using it from your code?
(no ui:field; unless you're relying on rootContent.getWidget(0) to
retrieve it?)
<div class="FormsContent"> should work just as well with less runtime
overhead.
> <g:HTMLPanel ui:field="_contentPanel"></g:HTMLPanel>
> </g:HTMLPanel>
> <div class="FormsBtm"> </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);
Any reason you're moving _contentPanel from the "FormsContent"
HTMLPanel to the "FormsBox" one? Why not having your UiBinder ui.xml
right as you want it to be?
> }
>
> }
>
> 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!
Where are you expecting the <h2>my box!</h2> to go?
If your MyBox widget implements HasHTML, then it should work (UiBinder
will call setHTML with "<h2>my box!</h2>"), otherwise, it doesn't know
what to do.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.