I finally managed to find a way to do this, but am in no way sure if I
haven't left a problem lurking somewhere underneath.
I had a table containing form elements that I wanted to use as a
UiBinder template. I didn't need event handling for most inputs, but
did want a click handler for a button. I tried Button.wrap, but it
looks like that only works for a button not already owned by a widget,
but my table binder becomes a widget, so that route was out.
It would be nice if there was some built-in way to "widgetize" an
element like that, so that from that point on normal GWT tasks could
be performed on it.
I used an HTML binder rather than a Widget binder because there was no
way I could have a table as the top-level element without using a tag
like <g:Grid>, which I wanted to avoid because then I can't edit the
layout easily, and also because I already have the table code. (One
goal of this was to take a number of existing JSP tag files and turn
them into GWT widgets via the binder. Other than the event issue,
that actually works out very well.)
Wrapping my table in something like a <g:HtmlPanel>, where I could use
a <g:Button> was out, since then the container div is the element that
my primary style affects, and setting its width allowed the table to
overflow the boundaries.
So, here is the line from my template:
<tr><td colspan="2"><button ui:field="saveButton">Save</button></td></
tr>
And, in the java file, my registration method:
public HandlerRegistration addSaveHandler(final ClickHandler handler)
{
return addDomHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (Element.as(event.getNativeEvent().getEventTarget())
==
saveButton)
handler.onClick(event);
}
}, ClickEvent.getType());
}
So, have I done everything that I need to to make this work reliably?
--
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.