In my case I have no choice.

If you just need it for one widget I agree it is maybe over-the-top. But I
want the rich behavior of custom widgets, without the cost of
re-implementing all the workarounds and tricks in my own onBrowserEvent
then wrapping is the way to go since all you do this way is to add the
required listeners.

I am bulk rendering the HTML of an editor that is driven by the XSD schema
of financial messages. There is such a huge amount of widgets needed that
it takes minutes to get it on the screen using the "supported" way. By
using the bulk render it takes a second or so for a few hundred of widgets
which a lot of nice dynamic behavior.

By using this trick, I can make that static html into standards widgets
without the huge cost. I can even delay converting to widgets based on
mouse movements over the HTML.

Note that there might be a better solution nowadays, I started doing this a
long time ago before Renderables or whatever features that were added
later. GWT documentation did not really receive as much focus as the new
code additions in the last years.

Maybe it is time that the section on making GWT GUIs more efficient a bit
more detailed.
I found that there are many things missing (Elemental ? where is it
described for example).
Some applications in the enterprise environment have a lot fields to enter,
not everything can be simplified by a simple search box as Google is used
to ;-)

David


On Mon, Jun 3, 2013 at 10:11 AM, Jens <jens.nehlme...@gmail.com> wrote:

> I think you kind of misuse the *.wrap() method. They are meant to be used
> with static html pages that you want to enhance with GWT.
>
> I think what you really want for now is to extend Widget and overwriting
> onBrowserEvent(), e.g.
>
> MyServerFormWidget extends Widget {
>
>   MyServerFormWidget() {
>     setElement(Document.get().createDivElement());
>     sinkEvents(Event.ONCLICK);
>   }
>
>   public void setServerGeneratedHtml(String html) {
>     getElement().setInnerHTML(html);
>   }
>
>   @Override
>   public void onBrowserEvent(Event event) {
>     super.onBrowserEvent(event);
>     int eventType = DOM.eventGetType(event);
>     if(eventType == Event.ONCLICK) {
>        //check event target element, if its the submit button
>        if(formSubmitButtonHasBeenClicked(event)) {
>           event.preventDefault();
>           onSubmitClickIntercepted();
>        }
>     }
>   }
>
>   private void onSubmitClickIntercepted() {
>     //do your stuff, e.g. read form data and fire higher level events like
> fireEvent(new SubmitEvent(formData)); so you could use
> GWT-RPC/RequestFactory/RequestBuilder to send the form data to the server.
> That way you don't have to write Servlets directly.
>   }
>
> }
>
>
> -- J.
>
> --
> 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+unsubscr...@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.
>
>
>

-- 
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+unsubscr...@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.


Reply via email to