1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    39
    Vote Rating
    0
    rmulcha is on a distinguished road

      0  

    Default Unanswered: Example for SafeStyles with XTemplate

    Unanswered: Example for SafeStyles with XTemplate


    Is there any example using SafeStyle with XTemplate please.

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,732
    Answers
    109
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    There are a few internal samples in the Base theme (com.sencha.gxt.theme.base.client.button.ButtonCellDefaultAppearance.render(ButtonCell<C>, Context, C, SafeHtmlBuilder), com.sencha.gxt.theme.base.client.button.ButtonCellDefaultAppearance.writeText(SafeHtmlBuilder, String, int, int)) and another in the Portal Layout (UiBinder) example. The basic idea is that you need to set a specific style on an element, and something that can't be set using CSS (and you should use CSS if possible, it will make building the string faster, and will make sure the style is only set in one place instead of every time the template is drawn). Build up the SafeStyle instance using the utilities provided by GWT (I.E. SafeStylesUtils, SafeStylesBuilder) and pass that as an argument to the template. In the template html body, reference that style within a style attribute of an element:

    Code:
    interface SafeStylesSampleTemplate extends XTemplates {
      @XTemplate("<div style='{customStyle}'>This element has a custom style</div>")
      SafeHtml renderWithCustomStyle(SafeStyles customStyle);
    }

Thread Participants: 1