Wednesday, November 3, 2010

Re: How can I use a Widget to edit a CellTree node?

GWT doesn't support what you are trying to do.  You cannot add a widget to an arbitrary element that is already a descendant of a widget.

There are two alternatives that could work.  You could create a Cell that switches to an editable via.  See EditableTextCell for an example.  Alternatively, you can position a PopupPanel with your editor widget directly over the cell.

Thanks,
John LaBanca
jlabanca@google.com


On Wed, Nov 3, 2010 at 10:11 AM, David Pinn <dpinn@byandlarge.net> wrote:
When the user edits a node of my CellTree, I want to inject a
composite widget into the tree at that point to handle the editing.

To experiment with this, I created the following custom TextArea sub-
class:

class MyTextArea extends TextArea {
 public static MyTextArea addToElement(Element parent) {
   MyTextArea textArea = new MyTextArea();
   parent.appendChild(textArea.getElement());

   textArea.onAttach();
   RootPanel.detachOnWindowClose(textArea);

   return textArea;
 }
}

When the user clicks on a node in the tree, I create an instance of
MyTextArea as follows:

   ta = MyTextArea.addToElement(parent);

Tragically, I'm getting the following error message: "A widget that
has an existing parent widget may not be added to the detach list"

I understand that when MyTextArea calls
parent.appendChild(textArea.getElement()), it attaches itself via a
chain of parent elements to the CellTree; and in doing so, it
disqualifies itself from registration in the 'detach list'.

Soooo...can you see a way to do what I'm trying to do?

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

No comments:

Post a Comment