But did you transform the string to a safeStyle using SafeStyleUtils?

I test this with no warnings…
interface Template extends SafeHtmlTemplates {
    @Template("<span style=\"{0}\">...</span>")
    SafeHtml span(SafeStyles value);
}
RootPanel.get().add(new 
HTML(template.span(SafeStylesUtils.fromTrustedString("background: red;"))));

On Mar 4, 2013, at 9:10 AM, Enrique Rodriguez <[email protected]> wrote:

> Your <ui:with> statement is exactly what I tried that gives the error.  To 
> summarize, using type='java.lang.String' gives the warning to use SafeStyles 
> and using type='com.google.gwt.safecss.shared.SafeStyles' gives the error to 
> use a String.
> 
> The change log you referenced (r10548) is "... to make SafeUri work as 
> expected." and further states "Similar will be needed for SafeStyles." which 
> makes me think this is intended but not yet supported behavior.
> 
> Enrique
> 
> 
> On Sun, Mar 3, 2013 at 11:58 PM, Ignacio Baca Moreno-Torres 
> <[email protected]> wrote:
> Have you tried this?
> <ui:with field='styles' type='com.google.gwt.safecss.shared.SafeStyles'/>
> Also you can add a one resource class and just specify the return type 
> correctly in the class (see 
> http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/test/com/google/gwt/uibinder/test/client/UiRendererUi.ui.xml?r=10548).
> 
> On Mar 4, 2013, at 2:59 AM, Enrique Rodriguez <[email protected]> wrote:
> 
>> I'm trying to port a GWT 2.4 AbstractCell that uses SafeHtmlTemplates to a 
>> GWT 2.5 AbstractCell that uses UiRenderer.  My problem is that when I set 
>> the CSS style directly on a div element, GWT logs the "CSS attribute 
>> context" warning in my logs.  Using a String, the Cell works fine albeit 
>> with the warning, but my attempts to pass a SafeStyles have failed.
>> 
>> In my GWT 2.4 AbstractCell I had a template that used SafeStyles:
>> 
>> @SafeHtmlTemplates.Template("<div style=\"{0}\">{1}</div>")
>>       SafeHtml cell(SafeStyles styles, SafeHtml value);
>> 
>> When I try passing a SafeStyles, I get the following error:
>> 
>> 17:18:33.582 [ERROR] [my.widgets] java.lang.String required, but {styles} 
>> returns com.google.gwt.safecss.shared.SafeStyles: &lt;div  
>> style='{styles}'&gt; (:28)
>> 
>> When I use a String, everything works correctly, however I get the expected 
>> "CSS attribute context" warning.
>> 
>> 17:16:51.108 [WARN] [my.widgets] Template with variable in CSS attribute 
>> context: The template code generator cannot guarantee HTML-safety of the 
>> template -- please inspect manually or use SafeStyles to specify arguments 
>> in a CSS attribute context
>> 
>> Incidentally, I had a similar issue passing an image URL.  The logs warned 
>> me to use SafeUri, which I did and it worked, so it appears that img 
>> recognizes a SafeUri but div won't recognize a SafeStyles.
>> 
>>         <div style="{styles}">
>>             <img alt="{name}" src="{image}" />
>>         </div>
>> 
>> Enrique
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Google Web Toolkit" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Google Web Toolkit" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Google Web Toolkit" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to