Okay, fixed my problem already ;-)
First of all, it seemes that you cannot implement both the HasWidgets
and HasHTML interface. Well, you can, but the UiBinder will only
accept the first one. This means that if you implement HasWidgets,
HasHTML, you can only add child widgets. If you implement HasHTML,
HasWidgets, you can only add HTML. This is quite easy to work around.
Simply just implement HasWidgets and add all HTML using an HTMLPanel.

Then the tricky part:
My GroupBox is subclassed from AbsolutePanel, which already implements
the HasWidgets interface. It seems though, that I have to declare that
interface again in my GroupBox class, else UiBinder won't recognize
it!
(Is this a bug?)

So the solution was simple: add the HasWidgets interface to the
GroupBox class declaration and we're done!

<g:HTMLPanel>
    <b:GroupBox caption="hello">
        Hello World
    </b:GroupBox>
    <b:GroupBox caption="buttons">
        <g:HTMLPanel>
            <g:Button ui:field="btnShow">Show</g:Button><br/>
            <g:Button ui:field="btnClear">Clear</g:Button>
        </g:HTMLPanel>
    </b:GroupBox>
</g:HTMLPanel>

Works like a charm now!


On 15 jun, 15:10, Joost Bloemsma <joost.a.bloem...@gmail.com> wrote:
> Hi,
>
> I've made a very simple GroupBox widget which works fine. I can add it
> in java to a panel, set caption and add widgets. But now I want to add
> it in a UiBinder template file.
> To enable it to contain HTML, I had to implement the HasHTML
> interface. Now the following works fine:
>
> <g:HTMLPanel>
>     <b:GroupBox caption="hello">
>         Hello World
>     </b:GroupBox>
> </g:HTMLPanel>
>
> Next step; I want to be able to add child widgets from within my
> template, eg:
>
> <g:HTMLPanel>
>     <b:GroupBox caption="buttons">
>         <g:Button ui:field="btnShow">Show</g:Button><br/>
>         <g:Button ui:field="btnClear">Clear</g:Button>
>     </b:GroupBox>
> </g:HTMLPanel>
>
> Even though my GroupBox class extends the AbsolutePanel class, which
> implements the HasWidgets interface, it fails with the following
> error:
> Found widget <g:Button ui:field='btnShow'> in an HTML context
>
> Has anybody an idea how I can add child widgets in my UiPanel
> template? How do I have to implement my container widget?
>
> Thanks, Joost

-- 
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-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to