Sunday, May 30, 2010

Re: ui:image, image within an anchor or a button

I got the same situation.
Currently my solution is only has anchor in ***.ui.xml image part was
added using code.
eg:
Image myImage = new Image();
monitorOverImage = new Image();

monitorImage.setUrl(IFMResources.INSTANCE.vehicleMonitor().getURL());

monitorOverImage.setUrl(IFMResources.INSTANCE.vehicleMonitor_over().getURL());
Is there any better solution?

On 4月24日, 上午12時38分, Carlos Aguayo <carlos.agu...@gmail.com> wrote:
> I'd like to have an image within an anchor or a button tag. I'm using
> the UiBinder and I need the anchor or button to be a widget so I can
> use their "HasClickHandlers" interface.
>
> I wanted to use an image widget so I can use an ImageResource,
> something like this:
>
> <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
> <ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
>              xmlns:g='urn:import:com.google.gwt.user.client.ui'>
>
>   <ui:with field='res' type='com.test.Test.Resources'/>
>
>   <g:HTMLPanel>
>     <g:Anchor><g:Image resource="{res.add}" /> Add</g:Anchor>
>   </g:HTMLPanel>
>
> </ui:UiBinder>
>
> But since neither the Anchor nor the Button can take widgets, I get
> the "Found widget in an HTML context" error.
>
> I've seen posts mentioning the "ui:image" tag but couldn't find
> documentation on how to use it and I couldn't get it to work.
>
> If I do:
>
> <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
> <ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
>              xmlns:g='urn:import:com.google.gwt.user.client.ui'>
>
>   <g:HTMLPanel>
>     <ui:image src="add.gif" />
>   </g:HTMLPanel>
>
> </ui:UiBinder>
>
> It's doing something since it won't compile if "add.gif" is not under
> the right package. However when I see it in the browser, the ui:image
> didn't get compiled into an image.
>
> Do you know what am I missing here?
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
> To post to this group, send email to google-web-toolkit@googlegroups.com.
> To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/google-web-toolkit?hl=en.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment