On Jan 3, 6:42 am, jarrod <[email protected]> wrote:
> While working with some of the new Layout widgets (DockLayoutPanel in
> particular), I noticed
> that older widgets, such as HTML, automatically set a default primary
> style name in the
> constructor, while the DockLayoutPanel does not.
>
> This isn't terrible in and of itself, but in my UiBinder template, I
> have the following code:
>
> <g:DockLayoutPanel styleName="{style.main}"
> addStyleNames="{global.style.html}" unit="PX">
> ...
> </g:DockLayoutPanel>
>
> When UiBinder generates the code for this element, the order of
> attribute processing is not
> preserved, and the resulting code is as follows:
>
> f_DockLayoutPanel1.addStyleName("" + global.style().html() + "");
> f_DockLayoutPanel1.setStyleName("" + style.main() + "");
>
> Because "setStyleName()" is called second, the previously added style
> names are blown away.

Well, why are you using *both* styleName and addStyleNames? why not
stick with only one? either styleName="{style.main}
{global.style.html}" or addStyleNames="{style.main}
{global.style.html}" (note that the first one is processed as a single
value passed directly to setStyleName while the second is parsed as a
list of tokens, calling addStyleName repeatedly).

(That being said, I agree this should be considered a bug,
addStyleName and addStyleDependentName should be called after setters,
but I don't know if this can be fixed easily, without having to change
UiBinder's internals too much)

> Additionally, for whatever reason, changing the "styleName" attribute
> on my DockLayoutPanel to
> "stylePrimaryName" yields exactly the same results. Yet on a <g:HTML /> 
> element, the
>
> combination of "stylePrimaryName" and "addStyleNames" works as
> expected.

That's because setStylePrimaryName works by replacing the very first
class and then replacing the equivalent prefix in the following
classes. Because the HTML widget has a default style name of gwt-HTML,
setting stylePrimaryName will replace gwt-HTML with the new value, and
leave the {style.main} and/or {global.style.html} as-is; while on
DockPanelLayout the addStyleNames="" will actually set the "primary
name" (as there's no pre-existing default style name), so
setStylePrimaryName will take the first addStyleNames value as the
"primary name" and replace it.

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to