On Apr 8, 12:33 pm, San <[email protected]> wrote:
> Hi all,
>
> I was trying to use UIBinders for my own custom widget.
>
> public class MyImageButton extends CustomButton{
>         public @UiConstructor MyImageButton(Image upImage) {
>                 super(upImage);
>                 // TODO Auto-generated constructor stub
>         }
>
> }
>
> My UiBinder.xml is as follows
>
> <g:FlowPanel ui:field="flowPanel">
>                         <my:MyImageButton 
> ui:field="imageButton"></my:MyImageButton>
> </g:FlowPanel>
>
> At run time I am getting following error
>
> 15:59:00.437 [ERROR] [toolbar] <my:MyImageButton
> ui:field='imageButton'> missing required attribute(s): upImage
>
> Can anyone help me how i cann set the attribute's value as a object of
> Image class in UI Binder.

You can only do so if your Image comes from a class "imported" with an
<ui:with> *or* if you provide a @UiFactory method or
@UiField(provided=true) the imageButton field.

This would result in, either:
   <ui:with field='res' type='com.company.myapp.client.SomeClass'
   ...
   <my:MyImageButton upImage='${res.myImage}' />
or
   <my:MyImageButton />
   ...
   @UiFactory MyImageButton createMyImageButton() {
      return new MyImageButton(myImage);
   }
or
   <my:MyImageButton field='imageButton' />
   ...
   @UiField(provided=true) MyImageButton imageButton;
   ...
   imageButton = new MyImageButton(myImage);
   ...
   binder.createAndBindUi(this);

You could also replace the Image with an ImageResource so you can call
the image's resource from the ui.xml with an <ui:image/>:
   <ui:image field='myImage' resource='path/to/myImage.png' />
   ...
   <my:MyImageButton upImage='${myImage}' />

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

Reply via email to