UiBinder and Constants in HTML

1,196 views
Skip to first unread message

dindeman

unread,
Mar 11, 2011, 1:43:36 AM3/11/11
to Google Web Toolkit
Hi everyone.

What's the best way to reuse a global constant within UiBinder ?

I did the following:

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

<ui:with field='cons' type='com.example.gwtpuibinder.client.MyCons'/>

<g:HTMLPanel>

<p>
At <g:Label text="{cons.businessName}"></g:Label> we strive for our
customers.
</p>

</g:HTMLPanel>
</ui:UiBinder>

It works but it's a bit heavy. It would be nice if I could use
something like @def statement for CSS constants, is there anything
like that that would do the above job?

Also I don't get why the Label produces a line break before and after
itself, it's a bit annoying since it can't be styled.

Hints would be very much appreciated.
Thank you.
Luc

Thomas Broyer

unread,
Mar 11, 2011, 4:35:15 AM3/11/11
to google-we...@googlegroups.com


On Friday, March 11, 2011 7:43:36 AM UTC+1, dindeman wrote:
Hi everyone.

What's the best way to reuse a global constant within UiBinder ?

I did the following:

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

<ui:with field='cons' type='com.example.gwtpuibinder.client.MyCons'/>

<g:HTMLPanel>

<p>
At <g:Label text="{cons.businessName}"></g:Label> we strive for our
customers.

How about:
At <ui:text from="{cons.businessName}" /> we strive for our customers.
It won't generate a widget, contrary to g:Label; much less overhead.
 
</p>

</g:HTMLPanel>
</ui:UiBinder>

It works but it's a bit heavy. It would be nice if I could use
something like @def statement for CSS constants, is there anything
like that that would do the above job?

What is heavy? defining the constants in an external interface? How about using <ui:msg/> then?
 
Also I don't get why the Label produces a line break before and after
itself,

That's because a Label is an HTML <div>
 
it's a bit annoying since it can't be styled.

Using an InlineLabel if you want a <span> instead.

dindeman

unread,
Mar 11, 2011, 5:15:17 AM3/11/11
to Google Web Toolkit
Hi Thomas.

Yes your suggestion of using <ui:text> perfectly does the job, this is
exactly what I was looking for, thank you.
Thanks also for the informative remark concerning the Label being a
<div>, it makes sense.

Regards.
Luc

On Mar 11, 4:35 pm, Thomas Broyer <t.bro...@gmail.com> wrote:
> On Friday, March 11, 2011 7:43:36 AM UTC+1, dindeman wrote:
>
> > Hi everyone.
>
> > What's the best way to reuse a global constant within UiBinder ?
>
> > I did the following:
>
> > <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
> > xmlns:g="urn:import:com.google.gwt.user.client.ui">
>
> > <ui:with field='cons' type='com.example.gwtpuibinder.client.MyCons'/>
>
> > <g:HTMLPanel>
>
> > <p>
> > At <g:Label text="{cons.businessName}"></g:Label> we strive for our
> > customers.
>
> How about:
> At <ui:text from="{cons.businessName}" /> we strive for our customers.
> It won't generate a widget, contrary to g:Label; much less overhead.
>
> > </p>
>
> > </g:HTMLPanel>
> > </ui:UiBinder>
>
> > It works but it's a bit heavy. It would be nice if I could use
> > something like @def statement for CSS constants, is there anything
> > like that that would do the above job?
>
> What is heavy? defining the constants in an external interface? How about
> using <ui:msg/> then?
> Seehttp://code.google.com/webtoolkit/doc/latest/DevGuideUiBinderI18n.html
Reply all
Reply to author
Forward
0 new messages