Thanks John, however this did not resolve my problem. I did what you
suggested but I'm still having trouble seeing the 'value' set on the
<input> elements. I did the following:
1) Change to extending AbstractEditableCell.
2) Changed to using a Template combined with a SafeHtml renderer for
the <input> tags.
3) Pick up the "change" event in onBrowserEvent (see code snippet
below)
4) Inspect DOM tree to get the appropriate InputElement, then call
getNodeValue() (see code snippet below)
The problem is that getNodeValue() is null, even when the Element is
definitely the correct one and after I have entered a value in the
<input> field. It seems that when I enter a value in the form field,
it doesn't make it onto the DOM tree, and therefore isn't seen by GWT.
Any suggestions?
----------
private static InputElement findElementTreeRecursive(Node n, String
id) {
if (n.getNodeType() == Node.ELEMENT_NODE) {
Element e = Element.as(n);
System.out.println(" let's compare element " + e.getId() + " with "
+ id);
if (e.getId().equals(id)) {
System.out.println("findElementTreeRecursive found element " +
e.getNodeName() + ", value= " + e.getNodeValue() + ", id= " +
e.getId());
return (InputElement) e;
}
}
NodeList<Node> childNodes = n.getChildNodes();
for (int i=0; i<childNodes.getLength(); i++) {
Node nDOM = childNodes.getItem(i);
findElementTreeRecursive(nDOM, id);
}
System.out.println("findElementTreeRecursive NOT FOUND ELEMENT :( ");
return null;
}
-----------------
@Override
public void onBrowserEvent(Element parent, NodeDTO value, Object key,
NativeEvent event, ValueUpdater valueUpdater) {
// Check that the value is not null.
if (value == null) {
return;
}
// Call the super handler, which handlers the enter key.
super.onBrowserEvent(parent, value, key, event, valueUpdater);
if ("change".equals(event.getType())) {
Element target = event.getEventTarget().cast();
// findElementTreeRecursive() is called within getInputElement()
InputElement inputPctComplete = getInputElement(parent,
ELEMENT_AGE_ID);
}
}
On Dec 4, 12:34 am, John LaBanca <
jlaba...@google.com> wrote:
> AbstractInputCell is intended to be wrap a single input element, not an
> entire form. Specifically, you need to override getInputElement(parent) to
> dig into the DOM and get the input element that you are wrapping. By
> default, getInputElement(parent) gets the first child of the parent,
> assuming that the cell renders a single input element and nothing else.
> Still, even if you override getInputElement, you'll only be able to return
> one value.
>
> What you really need to do is create a new AbstractEditableCell. In
> onBrowserEvent, catch the change event and dig down to all of the input
> elements in the form, updating the DTO as needed.
>
> Thanks,
> John LaBanca
>
jlaba...@google.com
> ...
>
> read more »