I have been getting the warning below for quite some time now and I
decided I finally wanted to do something about it.
[WARN] Template with variable in URL attribute context: The template
code generator cannot guarantee HTML-safety of the template -- please
inspect manually or use SafeUri to specify arguments in a URL
attribute context
It wasn't easy (because the warning doesn't give the slightest hint as
to where the problem might be) but I found the method that triggers
it: getLocation().
class MyWidget ... {
...
@UiConstructor
MyWidget(String location, ...) {
this.location = location;
...
}
...
String getLocation() {
return location;
}
}
This is used in MyWidget.ui.xml:
<ui:with field="widget" type="....MyWidget"/>
<g:HTMLPanel>
<object ... data="{widget.getLocation}">...</object>
</g:HTMLPanel>
The warning seems to indicate I should use something like
SafeUri getLocation() (which then returns a SafeUri wrapper of 'location')
but doing that results in
[ERROR] Returns interface com.google.gwt.safehtml.shared.SafeUri,
can't be used as class java.lang.String
So I guess that's not the right way then. And using SafeUri's asString
(i.e. "{widget.getLocation.asString}") gets me the original warning
back.
What should I do to get rid of the warning?
Cheers,
Hilco