On 14 Aug, 17:42, PeteUK <[email protected]> wrote: > On 12 Aug, 08:32, Andrew Hughes <[email protected]> wrote: > > > > > Thanks for all your help Nicolas.. > > > here's a brief summary of anyone looking to for a few hints (NOTE > > failWhale.png is located in the same directory as the ui.xml). > > > <!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:data field="failWhaleData" src="failWhale.png"/> > > <ui:image field="failWhaleImage" src="failWhale.png"/> > > <ui:style> > > �...@sprite .imageSprite { > > gwt-image: 'failWhaleImage' > > } > > </ui:style> > > <g:VerticalPanel ui:field="panel"> > > <g:SimplePanel addStyleNames="{style.imageSprite}"/> > > <g:Image resource="{failWhaleImage}"/> > > <g:Label text="{failWhaleImage.getURL}"/> > > <g:Label text="{failWhaleImage.getName}"/> > > </g:VerticalPanel> > > </ui:UiBinder> > > I am trying to learn about GWT, took your example and have it > working ok. I tried to do a simple extension to it and have been > running into problems and wondered if you or anyone else might > be able to help? > > I thought I'd try to output the height of the image in much the same > way > as you are outputting the url and name, so I added a label: > > <g:Label text="{failWhaleImage.getName}" /> > <g:Label text="{failWhaleImage.getHeight}" /> <!-- added by me! --> > > This fails because getHeight provides an int, not a String. > > My next thought was to create a UiField to represent the label and in > the > java code, get the height from the data, convert to String and call > SetText() > on the label: > > <g:Label text="{failWhaleImage.getName}" /> > <g:Label ui:field="heightLabel"/> <!-- added by me! --> > > The step that I didn't know how to make (or even if it is possible) is > to reference the ui:data field from within the Java code to make the > getHeight() call, or access the height attribute. Is this possible? >
I've figured it out doing the following in the Java code: @UiField ImageResource failWhaleImage; @UiField Label heightLabel; in constructor: heightLabel.setText(Integer.toString(failWhaleImage.getHeight())); Thanks, Pete -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
