Monday, December 16, 2013

Re: Create ImageResource from URL derived from DB?

I think Nolan wants to use APIs such as http://www.gwtproject.org/javadoc/latest/com/google/gwt/cell/client/ButtonCellBase.html#setIcon(com.google.gwt.resources.client.ImageResource) that expect an ImageResource.

On Monday, December 16, 2013 8:31:55 AM UTC+1, Benjamin Possolo wrote:
This is not what ImageResource was designed for. ImageResource is part of ClientBundle and is intended for bundling images into a single sprite map to reduce the number of network requests between the user's browser and your server. The artifacts are generated at compile time.

If you want to define the background image of your GWT Button widget (which is just a <button> or <input> element), use the DOM api and CSS to set the background to the desired image url.

String urlToImage = "http://www.foo.com/your-image.png";
Button b = new Button();
b.getElement().getStyle().setProperty("background", "url('" + urlToImage + "') no-repeat");

Here is a stackoverflow post that talks about setting background images on input elements
http://stackoverflow.com/questions/2738920/background-image-for-input-type-button


On Saturday, December 7, 2013 9:18:06 AM UTC-8, Nolan Brassard wrote:
Is there a way to create an ImageResource from a URL?

I have a scenario where I'd like to allow the user to give me a URL to an image that will then be used as the Icon of a certain button later on. The only way I know how to create an ImageResource is via a client bundle and setting @Source. Is there another way to do this?

--
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate