On Wednesday, April 3, 2013 12:34:06 AM UTC+2, Pat wrote:
I found something that works, even though I think that should be possible with less glue code...
It should be possible to create a SafeHtmlResource, that could validate the content of the resource at build-time.
Otherwise, your solution below is the only one I could think about.
interface TextsBundle extends ClientBundle { @Source("text.txt") TextResource myText(); }
class SafeHtmlTexts {
@Inject TextBundle texts;
public SafeHtml myText() { return SafeHtmlUtils.fromSafeConstant(texts.myText( ).getText()); }
}
class ViewImpl {
private final SafeHtmlTexts texts;
@Inject public ViewImpl(..., SafeHtmlTexts texts) { this.texts = texts; ... }
...
@UiFactory SafeHtmlTexts create() { return texts; }
You could simply use a @UiField for 'texts' rather than the @UiFactory. If you want the SafeHtmlTexts to be provided (by GIN apparently), use @UiField(provided=true) (and you can then have your field 'final').
}
ViewImpl.ui.xml:
<ui:with field='texts' type='....SafeHtmlTexts'/>
...
<div><ui:safehtml from="{texts.myText}"/></div>
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 google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
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.
No comments:
Post a Comment