Re: How to use g:DialogBox UIBinder definition from Java

2010-02-10 Thread Christian Goudreau
First, give us your code for you .java and for your .ui.xml.

I'll see what  I can do for you, I also had some problems first time I tried
this. Note that I'm using Gwt-Presenter in my example.

Christian

On Wed, Feb 10, 2010 at 10:24 AM, Stefano Ciccarelli
sciccare...@gmail.comwrote:

 Solution #1 doesn't work for me. I get this error:

 Second attempt to set initializer for field f_DialogBox1, from new
 com.google.gwt.user.client.ui.DialogBox(false, true) to
 owner.thatsJustMe()

 Hints or suggestions?


 On Tue, Feb 9, 2010 at 5:44 PM, Thomas Broyer t.bro...@gmail.com wrote:


 On Feb 9, 12:00 pm, Ovidiu Gheorghies ogheorgh...@gmail.com wrote:
  Hello,
 
  The DialogBox API (http://google-web-toolkit.googlecode.com/svn/
  javadoc/2.0/com/google/gwt/user/client/ui/DialogBox.html) notes that a
  DialogBox can be defined as a UIBinder template as follows:
 
   g:DialogBox autoHide=true modal=true
 g:captionbCaption text/b/g:caption
 g:HTMLPanel
   Body text
   g:Button ui:field='cancelButton'Cancel/g:Button
   g:Button ui:field='okButton'Okay/g:Button
 /g:HTMLPanel
   /g:DialogBox
 
  What is the proper way of using this definition from Java code?
  Supposing that the above definition is contained in
  NotificationWindow.ui.xml, the following naive approach to
  NotificationWindow.java does not work:
 
  public class NotificationWindow extends Composite {
  private static NotificationWindowUiBinder uiBinder =
  GWT.create(NotificationWindowUiBinder.class);
  interface NotificationWindowUiBinder extends UiBinderWidget,
  NotificationWindow {}
 
  @UiField DialogBox dialogBox;
 
  public NotificationWindow() {
  initWidget(uiBinder.createAndBindUi(this));
  }
 
  public void show() {
  dialogBox.show();
  }
 
  }
 
  If the EntryPoint-derived class calls:
 
  (new NotificationWindow()).show();
 
  then the following exception is logged:
 
  java.lang.IllegalStateException: This widget's parent does not
  implement HasWidgets
 
  How is the g:DialogBox definition from the DialogBox API used
  correctly from Java code?

 There are two possibilities: inheriting DialogBox or having a
 DialogBox field (but then not inheriting a Widget).

 Solution #1: inheriting a DialogBox

 class NotificationWindow extends DialogBox {
   ...

   public NotificationWindow() {
 // we don't care about the returned value, it'll be 'this'
 uiBinder.createAndBindUi(this);
   }

   @UiFactory
   DialogBox thatsJustMe() {
  // UiBinder will call this to get a DialogBox instance
  // and this is the DialogBox instance we want to use
  return this;
   }

   ...
 }


 Solution #2: not inheriting DialogBox

 // Note: do NOT inherit Composite, Widget or UIObject!
 class NotificationWindow {
   ...

   private DialogBox dialogBox;

   public NotificationWindow() {
  dialogBox = uiBinder.createAndBind(this);
}

   public void show() {
  dialogBox.show();
   }

...
 }

 --
 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-tool...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-web-toolkit+unsubscr...@googlegroups.comgoogle-web-toolkit%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://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-tool...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-web-toolkit+unsubscr...@googlegroups.comgoogle-web-toolkit%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://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-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: How to use g:DialogBox UIBinder definition from Java

2010-02-10 Thread Stefano Ciccarelli
Sorry, I was talking about Thomas Broyer solution #1.
Your code (pastebin) is what I was already doing.

BTW this is the .java:

public final class AboutDialogDisplay {
@Inject
private AboutDialogDisplay() {
uiBinder.createAndBindUi(this);
}

@UiFactory
DialogBox thatsJustMe() {
return this;
}
}

And this is the .ui.xml:
g:DialogBox animationEnabled=true glassEnabled=true modal=true
..
/g:DialogBox

Thanks
Stefano



On Wed, Feb 10, 2010 at 4:46 PM, Christian Goudreau 
goudreau.christ...@gmail.com wrote:

 First, give us your code for you .java and for your .ui.xml.

 I'll see what  I can do for you, I also had some problems first time I
 tried this. Note that I'm using Gwt-Presenter in my example.

 Christian

 On Wed, Feb 10, 2010 at 10:24 AM, Stefano Ciccarelli 
 sciccare...@gmail.com wrote:

 Solution #1 doesn't work for me. I get this error:

 Second attempt to set initializer for field f_DialogBox1, from new
 com.google.gwt.user.client.ui.DialogBox(false, true) to
 owner.thatsJustMe()

 Hints or suggestions?


 On Tue, Feb 9, 2010 at 5:44 PM, Thomas Broyer t.bro...@gmail.com wrote:


 On Feb 9, 12:00 pm, Ovidiu Gheorghies ogheorgh...@gmail.com wrote:
  Hello,
 
  The DialogBox API (http://google-web-toolkit.googlecode.com/svn/
  javadoc/2.0/com/google/gwt/user/client/ui/DialogBox.html) notes that a
  DialogBox can be defined as a UIBinder template as follows:
 
   g:DialogBox autoHide=true modal=true
 g:captionbCaption text/b/g:caption
 g:HTMLPanel
   Body text
   g:Button ui:field='cancelButton'Cancel/g:Button
   g:Button ui:field='okButton'Okay/g:Button
 /g:HTMLPanel
   /g:DialogBox
 
  What is the proper way of using this definition from Java code?
  Supposing that the above definition is contained in
  NotificationWindow.ui.xml, the following naive approach to
  NotificationWindow.java does not work:
 
  public class NotificationWindow extends Composite {
  private static NotificationWindowUiBinder uiBinder =
  GWT.create(NotificationWindowUiBinder.class);
  interface NotificationWindowUiBinder extends UiBinderWidget,
  NotificationWindow {}
 
  @UiField DialogBox dialogBox;
 
  public NotificationWindow() {
  initWidget(uiBinder.createAndBindUi(this));
  }
 
  public void show() {
  dialogBox.show();
  }
 
  }
 
  If the EntryPoint-derived class calls:
 
  (new NotificationWindow()).show();
 
  then the following exception is logged:
 
  java.lang.IllegalStateException: This widget's parent does not
  implement HasWidgets
 
  How is the g:DialogBox definition from the DialogBox API used
  correctly from Java code?

 There are two possibilities: inheriting DialogBox or having a
 DialogBox field (but then not inheriting a Widget).

 Solution #1: inheriting a DialogBox

 class NotificationWindow extends DialogBox {
   ...

   public NotificationWindow() {
 // we don't care about the returned value, it'll be 'this'
 uiBinder.createAndBindUi(this);
   }

   @UiFactory
   DialogBox thatsJustMe() {
  // UiBinder will call this to get a DialogBox instance
  // and this is the DialogBox instance we want to use
  return this;
   }

   ...
 }


 Solution #2: not inheriting DialogBox

 // Note: do NOT inherit Composite, Widget or UIObject!
 class NotificationWindow {
   ...

   private DialogBox dialogBox;

   public NotificationWindow() {
  dialogBox = uiBinder.createAndBind(this);
}

   public void show() {
  dialogBox.show();
   }

...
 }

 --
 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+unsubscr...@googlegroups.comgoogle-web-toolkit%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://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-tool...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-web-toolkit+unsubscr...@googlegroups.comgoogle-web-toolkit%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://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-tool...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-web-toolkit+unsubscr...@googlegroups.comgoogle-web-toolkit%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://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 

Re: How to use g:DialogBox UIBinder definition from Java

2010-02-10 Thread Christian Goudreau
In your code, for solution #1, you need to extends DialogBox, you forgot
that.

For my solution, I only encapsulate DialogBox within an HTMLPanel an then I
added two public function for showing and hiding my dialogbox. (Solution #2)
Btw, I found solution #2 less intrusive and more simple.

On Wed, Feb 10, 2010 at 10:58 AM, Stefano Ciccarelli
sciccare...@gmail.comwrote:

 Sorry, I was talking about Thomas Broyer solution #1.
 Your code (pastebin) is what I was already doing.

 BTW this is the .java:

 public final class AboutDialogDisplay {
 @Inject
 private AboutDialogDisplay() {
 uiBinder.createAndBindUi(this);
 }

 @UiFactory
 DialogBox thatsJustMe() {
 return this;
 }
 }

 And this is the .ui.xml:
 g:DialogBox animationEnabled=true glassEnabled=true modal=true
 ..
 /g:DialogBox

 Thanks
 Stefano



 On Wed, Feb 10, 2010 at 4:46 PM, Christian Goudreau 
 goudreau.christ...@gmail.com wrote:

 First, give us your code for you .java and for your .ui.xml.

 I'll see what  I can do for you, I also had some problems first time I
 tried this. Note that I'm using Gwt-Presenter in my example.

 Christian

 On Wed, Feb 10, 2010 at 10:24 AM, Stefano Ciccarelli 
 sciccare...@gmail.com wrote:

 Solution #1 doesn't work for me. I get this error:

 Second attempt to set initializer for field f_DialogBox1, from new
 com.google.gwt.user.client.ui.DialogBox(false, true) to
 owner.thatsJustMe()

 Hints or suggestions?


 On Tue, Feb 9, 2010 at 5:44 PM, Thomas Broyer t.bro...@gmail.comwrote:


 On Feb 9, 12:00 pm, Ovidiu Gheorghies ogheorgh...@gmail.com wrote:
  Hello,
 
  The DialogBox API (http://google-web-toolkit.googlecode.com/svn/
  javadoc/2.0/com/google/gwt/user/client/ui/DialogBox.html) notes that a
  DialogBox can be defined as a UIBinder template as follows:
 
   g:DialogBox autoHide=true modal=true
 g:captionbCaption text/b/g:caption
 g:HTMLPanel
   Body text
   g:Button ui:field='cancelButton'Cancel/g:Button
   g:Button ui:field='okButton'Okay/g:Button
 /g:HTMLPanel
   /g:DialogBox
 
  What is the proper way of using this definition from Java code?
  Supposing that the above definition is contained in
  NotificationWindow.ui.xml, the following naive approach to
  NotificationWindow.java does not work:
 
  public class NotificationWindow extends Composite {
  private static NotificationWindowUiBinder uiBinder =
  GWT.create(NotificationWindowUiBinder.class);
  interface NotificationWindowUiBinder extends UiBinderWidget,
  NotificationWindow {}
 
  @UiField DialogBox dialogBox;
 
  public NotificationWindow() {
  initWidget(uiBinder.createAndBindUi(this));
  }
 
  public void show() {
  dialogBox.show();
  }
 
  }
 
  If the EntryPoint-derived class calls:
 
  (new NotificationWindow()).show();
 
  then the following exception is logged:
 
  java.lang.IllegalStateException: This widget's parent does not
  implement HasWidgets
 
  How is the g:DialogBox definition from the DialogBox API used
  correctly from Java code?

 There are two possibilities: inheriting DialogBox or having a
 DialogBox field (but then not inheriting a Widget).

 Solution #1: inheriting a DialogBox

 class NotificationWindow extends DialogBox {
   ...

   public NotificationWindow() {
 // we don't care about the returned value, it'll be 'this'
 uiBinder.createAndBindUi(this);
   }

   @UiFactory
   DialogBox thatsJustMe() {
  // UiBinder will call this to get a DialogBox instance
  // and this is the DialogBox instance we want to use
  return this;
   }

   ...
 }


 Solution #2: not inheriting DialogBox

 // Note: do NOT inherit Composite, Widget or UIObject!
 class NotificationWindow {
   ...

   private DialogBox dialogBox;

   public NotificationWindow() {
  dialogBox = uiBinder.createAndBind(this);
}

   public void show() {
  dialogBox.show();
   }

...
 }

 --
 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-tool...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-web-toolkit+unsubscr...@googlegroups.comgoogle-web-toolkit%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://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+unsubscr...@googlegroups.comgoogle-web-toolkit%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://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 

Re: How to use g:DialogBox UIBinder definition from Java

2010-02-10 Thread Christian Goudreau
Oh no his solution #2 isn't like mine at all, lol, but anyway, do you really
need @Inject ? There's nothing to inject in your example.

On Wed, Feb 10, 2010 at 11:11 AM, Christian Goudreau 
goudreau.christ...@gmail.com wrote:

 In your code, for solution #1, you need to extends DialogBox, you forgot
 that.

 For my solution, I only encapsulate DialogBox within an HTMLPanel an then I
 added two public function for showing and hiding my dialogbox. (Solution #2)
 Btw, I found solution #2 less intrusive and more simple.


 On Wed, Feb 10, 2010 at 10:58 AM, Stefano Ciccarelli 
 sciccare...@gmail.com wrote:

 Sorry, I was talking about Thomas Broyer solution #1.
 Your code (pastebin) is what I was already doing.

 BTW this is the .java:

 public final class AboutDialogDisplay {
 @Inject
 private AboutDialogDisplay() {
 uiBinder.createAndBindUi(this);
 }

 @UiFactory
 DialogBox thatsJustMe() {
  return this;
 }
 }

 And this is the .ui.xml:
 g:DialogBox animationEnabled=true glassEnabled=true modal=true
 ..
 /g:DialogBox

 Thanks
 Stefano



 On Wed, Feb 10, 2010 at 4:46 PM, Christian Goudreau 
 goudreau.christ...@gmail.com wrote:

 First, give us your code for you .java and for your .ui.xml.

 I'll see what  I can do for you, I also had some problems first time I
 tried this. Note that I'm using Gwt-Presenter in my example.

 Christian

 On Wed, Feb 10, 2010 at 10:24 AM, Stefano Ciccarelli 
 sciccare...@gmail.com wrote:

 Solution #1 doesn't work for me. I get this error:

 Second attempt to set initializer for field f_DialogBox1, from new
 com.google.gwt.user.client.ui.DialogBox(false, true) to
 owner.thatsJustMe()

 Hints or suggestions?


 On Tue, Feb 9, 2010 at 5:44 PM, Thomas Broyer t.bro...@gmail.comwrote:


 On Feb 9, 12:00 pm, Ovidiu Gheorghies ogheorgh...@gmail.com wrote:
  Hello,
 
  The DialogBox API (http://google-web-toolkit.googlecode.com/svn/
  javadoc/2.0/com/google/gwt/user/client/ui/DialogBox.html) notes that
 a
  DialogBox can be defined as a UIBinder template as follows:
 
   g:DialogBox autoHide=true modal=true
 g:captionbCaption text/b/g:caption
 g:HTMLPanel
   Body text
   g:Button ui:field='cancelButton'Cancel/g:Button
   g:Button ui:field='okButton'Okay/g:Button
 /g:HTMLPanel
   /g:DialogBox
 
  What is the proper way of using this definition from Java code?
  Supposing that the above definition is contained in
  NotificationWindow.ui.xml, the following naive approach to
  NotificationWindow.java does not work:
 
  public class NotificationWindow extends Composite {
  private static NotificationWindowUiBinder uiBinder =
  GWT.create(NotificationWindowUiBinder.class);
  interface NotificationWindowUiBinder extends UiBinderWidget,
  NotificationWindow {}
 
  @UiField DialogBox dialogBox;
 
  public NotificationWindow() {
  initWidget(uiBinder.createAndBindUi(this));
  }
 
  public void show() {
  dialogBox.show();
  }
 
  }
 
  If the EntryPoint-derived class calls:
 
  (new NotificationWindow()).show();
 
  then the following exception is logged:
 
  java.lang.IllegalStateException: This widget's parent does not
  implement HasWidgets
 
  How is the g:DialogBox definition from the DialogBox API used
  correctly from Java code?

 There are two possibilities: inheriting DialogBox or having a
 DialogBox field (but then not inheriting a Widget).

 Solution #1: inheriting a DialogBox

 class NotificationWindow extends DialogBox {
   ...

   public NotificationWindow() {
 // we don't care about the returned value, it'll be 'this'
 uiBinder.createAndBindUi(this);
   }

   @UiFactory
   DialogBox thatsJustMe() {
  // UiBinder will call this to get a DialogBox instance
  // and this is the DialogBox instance we want to use
  return this;
   }

   ...
 }


 Solution #2: not inheriting DialogBox

 // Note: do NOT inherit Composite, Widget or UIObject!
 class NotificationWindow {
   ...

   private DialogBox dialogBox;

   public NotificationWindow() {
  dialogBox = uiBinder.createAndBind(this);
}

   public void show() {
  dialogBox.show();
   }

...
 }

 --
 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-tool...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-web-toolkit+unsubscr...@googlegroups.comgoogle-web-toolkit%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://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-tool...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-web-toolkit+unsubscr...@googlegroups.comgoogle-web-toolkit%2bunsubscr...@googlegroups.com
 .
 For more 

Re: How to use g:DialogBox UIBinder definition from Java

2010-02-10 Thread Stefano Ciccarelli
I'm already doing like you, but I'd like to try the solution #1 explained by
Thomas Broyer, so the code is from that test. The class already extends
DialogBox and I get the error reported, the extends is missing because I
done something wrong with cutpaste.
I need @Inject because that class is the Display injected in a Presenter.

I want to try that solution because I prefer to extends DialogBox.


On Wed, Feb 10, 2010 at 5:16 PM, Christian Goudreau 
goudreau.christ...@gmail.com wrote:

 Oh no his solution #2 isn't like mine at all, lol, but anyway, do you
 really need @Inject ? There's nothing to inject in your example.


 On Wed, Feb 10, 2010 at 11:11 AM, Christian Goudreau 
 goudreau.christ...@gmail.com wrote:

 In your code, for solution #1, you need to extends DialogBox, you forgot
 that.

 For my solution, I only encapsulate DialogBox within an HTMLPanel an then
 I added two public function for showing and hiding my dialogbox. (Solution
 #2) Btw, I found solution #2 less intrusive and more simple.


 On Wed, Feb 10, 2010 at 10:58 AM, Stefano Ciccarelli 
 sciccare...@gmail.com wrote:

 Sorry, I was talking about Thomas Broyer solution #1.
 Your code (pastebin) is what I was already doing.

 BTW this is the .java:

 public final class AboutDialogDisplay {
 @Inject
 private AboutDialogDisplay() {
 uiBinder.createAndBindUi(this);
 }

 @UiFactory
 DialogBox thatsJustMe() {
  return this;
 }
 }

 And this is the .ui.xml:
 g:DialogBox animationEnabled=true glassEnabled=true modal=true
 ..
 /g:DialogBox

 Thanks
 Stefano



 On Wed, Feb 10, 2010 at 4:46 PM, Christian Goudreau 
 goudreau.christ...@gmail.com wrote:

 First, give us your code for you .java and for your .ui.xml.

 I'll see what  I can do for you, I also had some problems first time I
 tried this. Note that I'm using Gwt-Presenter in my example.

 Christian

 On Wed, Feb 10, 2010 at 10:24 AM, Stefano Ciccarelli 
 sciccare...@gmail.com wrote:

 Solution #1 doesn't work for me. I get this error:

 Second attempt to set initializer for field f_DialogBox1, from new
 com.google.gwt.user.client.ui.DialogBox(false, true) to
 owner.thatsJustMe()

 Hints or suggestions?


 On Tue, Feb 9, 2010 at 5:44 PM, Thomas Broyer t.bro...@gmail.comwrote:


 On Feb 9, 12:00 pm, Ovidiu Gheorghies ogheorgh...@gmail.com wrote:
  Hello,
 
  The DialogBox API (http://google-web-toolkit.googlecode.com/svn/
  javadoc/2.0/com/google/gwt/user/client/ui/DialogBox.html) notes that
 a
  DialogBox can be defined as a UIBinder template as follows:
 
   g:DialogBox autoHide=true modal=true
 g:captionbCaption text/b/g:caption
 g:HTMLPanel
   Body text
   g:Button ui:field='cancelButton'Cancel/g:Button
   g:Button ui:field='okButton'Okay/g:Button
 /g:HTMLPanel
   /g:DialogBox
 
  What is the proper way of using this definition from Java code?
  Supposing that the above definition is contained in
  NotificationWindow.ui.xml, the following naive approach to
  NotificationWindow.java does not work:
 
  public class NotificationWindow extends Composite {
  private static NotificationWindowUiBinder uiBinder =
  GWT.create(NotificationWindowUiBinder.class);
  interface NotificationWindowUiBinder extends
 UiBinderWidget,
  NotificationWindow {}
 
  @UiField DialogBox dialogBox;
 
  public NotificationWindow() {
  initWidget(uiBinder.createAndBindUi(this));
  }
 
  public void show() {
  dialogBox.show();
  }
 
  }
 
  If the EntryPoint-derived class calls:
 
  (new NotificationWindow()).show();
 
  then the following exception is logged:
 
  java.lang.IllegalStateException: This widget's parent does not
  implement HasWidgets
 
  How is the g:DialogBox definition from the DialogBox API used
  correctly from Java code?

 There are two possibilities: inheriting DialogBox or having a
 DialogBox field (but then not inheriting a Widget).

 Solution #1: inheriting a DialogBox

 class NotificationWindow extends DialogBox {
   ...

   public NotificationWindow() {
 // we don't care about the returned value, it'll be 'this'
 uiBinder.createAndBindUi(this);
   }

   @UiFactory
   DialogBox thatsJustMe() {
  // UiBinder will call this to get a DialogBox instance
  // and this is the DialogBox instance we want to use
  return this;
   }

   ...
 }


 Solution #2: not inheriting DialogBox

 // Note: do NOT inherit Composite, Widget or UIObject!
 class NotificationWindow {
   ...

   private DialogBox dialogBox;

   public NotificationWindow() {
  dialogBox = uiBinder.createAndBind(this);
}

   public void show() {
  dialogBox.show();
   }

...
 }

 --
 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-tool...@googlegroups.com.
 To unsubscribe from this group, send email to
 

How to use g:DialogBox UIBinder definition from Java

2010-02-09 Thread Ovidiu Gheorghies
Hello,

The DialogBox API (http://google-web-toolkit.googlecode.com/svn/
javadoc/2.0/com/google/gwt/user/client/ui/DialogBox.html) notes that a
DialogBox can be defined as a UIBinder template as follows:

 g:DialogBox autoHide=true modal=true
   g:captionbCaption text/b/g:caption
   g:HTMLPanel
 Body text
 g:Button ui:field='cancelButton'Cancel/g:Button
 g:Button ui:field='okButton'Okay/g:Button
   /g:HTMLPanel
 /g:DialogBox

What is the proper way of using this definition from Java code?
Supposing that the above definition is contained in
NotificationWindow.ui.xml, the following naive approach to
NotificationWindow.java does not work:

public class NotificationWindow extends Composite {
private static NotificationWindowUiBinder uiBinder =
GWT.create(NotificationWindowUiBinder.class);
interface NotificationWindowUiBinder extends UiBinderWidget,
NotificationWindow {}

@UiField DialogBox dialogBox;

public NotificationWindow() {
initWidget(uiBinder.createAndBindUi(this));
}

public void show() {
dialogBox.show();
}
}

If the EntryPoint-derived class calls:

(new NotificationWindow()).show();

then the following exception is logged:

java.lang.IllegalStateException: This widget's parent does not
implement HasWidgets

How is the g:DialogBox definition from the DialogBox API used
correctly from Java code?

Best regards,
Ovidiu

-- 
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-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: How to use g:DialogBox UIBinder definition from Java

2010-02-09 Thread Christian Goudreau
That's how :

http://pastie.org/816302

Christian

On Tue, Feb 9, 2010 at 6:00 AM, Ovidiu Gheorghies ogheorgh...@gmail.comwrote:

 Hello,

 The DialogBox API (http://google-web-toolkit.googlecode.com/svn/
 javadoc/2.0/com/google/gwt/user/client/ui/DialogBox.html) notes that a
 DialogBox can be defined as a UIBinder template as follows:

  g:DialogBox autoHide=true modal=true
   g:captionbCaption text/b/g:caption
   g:HTMLPanel
 Body text
 g:Button ui:field='cancelButton'Cancel/g:Button
 g:Button ui:field='okButton'Okay/g:Button
   /g:HTMLPanel
  /g:DialogBox

 What is the proper way of using this definition from Java code?
 Supposing that the above definition is contained in
 NotificationWindow.ui.xml, the following naive approach to
 NotificationWindow.java does not work:

 public class NotificationWindow extends Composite {
private static NotificationWindowUiBinder uiBinder =
 GWT.create(NotificationWindowUiBinder.class);
interface NotificationWindowUiBinder extends UiBinderWidget,
 NotificationWindow {}

@UiField DialogBox dialogBox;

public NotificationWindow() {
initWidget(uiBinder.createAndBindUi(this));
}

public void show() {
dialogBox.show();
}
 }

 If the EntryPoint-derived class calls:

 (new NotificationWindow()).show();

 then the following exception is logged:

 java.lang.IllegalStateException: This widget's parent does not
 implement HasWidgets

 How is the g:DialogBox definition from the DialogBox API used
 correctly from Java code?

 Best regards,
 Ovidiu

 --
 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-tool...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-web-toolkit+unsubscr...@googlegroups.comgoogle-web-toolkit%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://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-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: How to use g:DialogBox UIBinder definition from Java

2010-02-09 Thread Thomas Broyer

On Feb 9, 12:00 pm, Ovidiu Gheorghies ogheorgh...@gmail.com wrote:
 Hello,

 The DialogBox API (http://google-web-toolkit.googlecode.com/svn/
 javadoc/2.0/com/google/gwt/user/client/ui/DialogBox.html) notes that a
 DialogBox can be defined as a UIBinder template as follows:

  g:DialogBox autoHide=true modal=true
    g:captionbCaption text/b/g:caption
    g:HTMLPanel
      Body text
      g:Button ui:field='cancelButton'Cancel/g:Button
      g:Button ui:field='okButton'Okay/g:Button
    /g:HTMLPanel
  /g:DialogBox

 What is the proper way of using this definition from Java code?
 Supposing that the above definition is contained in
 NotificationWindow.ui.xml, the following naive approach to
 NotificationWindow.java does not work:

 public class NotificationWindow extends Composite {
         private static NotificationWindowUiBinder uiBinder =
 GWT.create(NotificationWindowUiBinder.class);
         interface NotificationWindowUiBinder extends UiBinderWidget,
 NotificationWindow {}

         @UiField DialogBox dialogBox;

         public NotificationWindow() {
                 initWidget(uiBinder.createAndBindUi(this));
         }

         public void show() {
             dialogBox.show();
     }

 }

 If the EntryPoint-derived class calls:

 (new NotificationWindow()).show();

 then the following exception is logged:

 java.lang.IllegalStateException: This widget's parent does not
 implement HasWidgets

 How is the g:DialogBox definition from the DialogBox API used
 correctly from Java code?

There are two possibilities: inheriting DialogBox or having a
DialogBox field (but then not inheriting a Widget).

Solution #1: inheriting a DialogBox

class NotificationWindow extends DialogBox {
   ...

   public NotificationWindow() {
 // we don't care about the returned value, it'll be 'this'
 uiBinder.createAndBindUi(this);
   }

   @UiFactory
   DialogBox thatsJustMe() {
  // UiBinder will call this to get a DialogBox instance
  // and this is the DialogBox instance we want to use
  return this;
   }

   ...
}


Solution #2: not inheriting DialogBox

// Note: do NOT inherit Composite, Widget or UIObject!
class NotificationWindow {
   ...

   private DialogBox dialogBox;

   public NotificationWindow() {
  dialogBox = uiBinder.createAndBind(this);
   }

   public void show() {
  dialogBox.show();
   }

   ...
}

-- 
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-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.