Thursday, August 29, 2013

Re: use GwtCreateResource to provide text programatically

What you're asking for could be (in my humble opinion) useful.  But, as things currently stand, it won't work syntactically.  The method in the bundle doesn't return the resource, it returns an object that lets you create the resource.  So, if anything was going to work at all, it would be:

{res.labels.create.title}
Eclipse code-assistance actually suggests create after res.labels. - but then flags the completed expression as an error.


On Tuesday, August 27, 2013 4:57:51 AM UTC-4, Jordan Amar wrote:

I would like my uiBinder to use a ClientBundle which will provide some runtime customized labels. Kind of a TextResource but not from a text file !
I tried with GwtCreateResource but from the DevGuide it seems like it's not possible. Am I right ? (create() and name() are the only methods available) What I would like to achieve is something like this:

client bundle:

public interface MyWidgetResources extends ClientBundle {      GwtCreateResource<WidgetLabels> labels();        @Source("lol.css")      CssResource style();  }  

labels class:

public final class MyWidgetLabels {      public String title() {          return load("mywidget-title");      }        public String banner() {          return load("mywidget-banner");      }        private String load(String key) {          // load from external..      }  }  

uiBinder:

<ui:with type="com.package.MyWidgetResources" field="res"/>    <gwt:SimplePanel>      <gwt:Label text="{res.labels.title}"></gwt:Label>      <gwt:Label text="{res.labels.banner}"></gwt:Label>  </gwt:SimplePanel>  

My code looks like this already but res.label.title does not work. I could try to first store a reference to res.labels.create but it seems like I can't access any methods of labels in my uiBinder.

Is there a solution for me ? Maybe with a custom ResourceGenerator ? In this case some more pointers would be welcomed because i didn't really catch how that worked...

Thanks !

--
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/groups/opt_out.

No comments:

Post a Comment