Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use variables in UiBinder style definitions in GWT

Tags:

gwt

uibinder

In the following example, from a file MessageView.ui.xml:

<ui:style>
    .polite {
      position:fixed;
      background-color:notice-background-color;
      top:1em;
      left:2em;
      white-space:nowrap;
      border-radius:.5em;}
</ui:style>

<g:PopupPanel styleName="{style.polite}">
    <g:HTML ui:field="message">Message goes here.</g:HTML>
</g:PopupPanel>

can I define @notice-background-color such that other UiBinder files can also use the definition.

like image 823
Carl Avatar asked Nov 28 '25 12:11

Carl


1 Answers

Yes you can. Define your color as static String:

package com.myproject.client.resource;

public class MyColors {
    public static String lightGreen = "#0bdc1a";
}

And define an @eval variable:

<ui:style>
    @eval notice-background-color com.myproject.client.resource.MyColors.lightGreen;

    .polite {
      position:fixed;
      background-color:notice-background-color;
      top:1em;
      left:2em;
      white-space:nowrap;
      border-radius:.5em;}
</ui:style>

<g:PopupPanel styleName="{style.polite}">
    <g:HTML ui:field="message">Message goes here.</g:HTML>
</g:PopupPanel>
like image 68
spg Avatar answered Dec 01 '25 01:12

spg