Monday, June 3, 2013

Re: Dynamically generated HTML and GWT



On Monday, June 3, 2013 9:39:08 AM UTC+2, stuckagain wrote:
Hi,
 
OK, I forgot about that part - I once had to go through these issues as well but forgot soon after.
 
You need to subclass HTMLPanel and SubmitButton to get what you want. The HTMLPanel only supports adding widgets to existing HTML elements, not just make an Element into a widget without detaching.
 
First you need to subclass the SubmitButton so that you gain access to the SubmitButton(Element) protected constructor. Use that constructor to create the SubmitButton instance.
 
You also need to subclass the HTMLPanel class, you need to add a method that contains something like this:

public attachWidget( Widget widget ) {
  // Logical attach.
  getChildren().add(widget);
  adopt(widget);
}

This method does not enforce any checks, so make sure that the widget is a wrapped one of an Element contained in the HTMLPanel.
 
Frankly I don't understand why the HTMLPanel and the Wrapping stuff does not allow you to do this. It is way more useful because you can bulk render and entire GUI and then later attach the widgets.

I believe this is what Renderable is supposed to add; but it's too easy to shoot yourself in the foot with this 2-step process. Should there be wrap(HTMLPanel, Element) overloads to "wrappable" widgets?
Feel free to propose a patch.

--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment