Monday, June 16, 2014

Re: Message Interfaces and SafeUri

Since the example supplied by Thomas does not quite work as written, I've included the working code segment below:

In the UiBinder xml file:
<ui:with field='mktRsc' type='com.example.i18n.MarketingResources' />    <!-- Work around to insert SAFE URL's from messages -->  <ui:with field="facebookUrl"    type="com.google.gwt.safehtml.shared.SafeUri" />  <ui:with field="twitterUrl"    type="com.google.gwt.safehtml.shared.SafeUri" />  <ui:with field="googlePlusUrl"    type="com.google.gwt.safehtml.shared.SafeUri" />  ...  <a target="_blank" href="{googlePlusUrl}">    <ui:text from="{mktMsg.followOnGPlus}"/>  </a>  

In the Java file for the UiBinder:

final MarketingResources mktRsc = GWT.create(MarketingResources.class);  
@UiField(provided=true)  SafeUri facebookUrl = UriUtils.fromSafeConstant(mktRsc.facebookUrl());  @UiField(provided=true)  SafeUri twitterUrl = UriUtils.fromSafeConstant(mktRsc.twitterUrl());  @UiField(provided=true)  SafeUri googlePlusUrl = UriUtils.fromSafeConstant(mktRsc.googlePlustUrl());  

Hope someone finds that helpful.

Sincerely,
Joseph

--
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.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment