You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Doug Leeper <do...@yahoo.com> on 2007/11/12 05:22:14 UTC
TreeModel error
Has anyone else come across this when inserting a node into a Tree:
java.lang.UnsupportedOperationException
at java.util.AbstractList.add(AbstractList.java:151)
at
org.apache.wicket.markup.html.tree.AbstractTree.treeNodesInserted(AbstractTree.java:779)
at
javax.swing.tree.DefaultTreeModel.fireTreeNodesInserted(DefaultTreeModel.java:497)
at
javax.swing.tree.DefaultTreeModel.nodesWereInserted(DefaultTreeModel.java:294)
at
javax.swing.tree.DefaultTreeModel.insertNodeInto(DefaultTreeModel.java:223)
at
homeiq.wicket.building.tree.BuildingTreeModel.addRoom(BuildingTreeModel.java:79)
at
homeiq.wicket.building.tree.ModalNewRoom$1.onSubmit(ModalNewRoom.java:36)
I traced through and saw a Vector was being created but not sure why it
wouldn't support add( int, Object ).
Any ideas?
- Doug
--
View this message in context: http://www.nabble.com/TreeModel-error-tf4788794.html#a13699585
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: TreeModel error
Posted by Matej Knopp <ma...@gmail.com>.
Thanks for the issue. Looks like a bug in AbstractTree.
-Matej
On Nov 12, 2007 5:47 AM, Doug Leeper <do...@yahoo.com> wrote:
>
> JIRA issue created ( http://issues.apache.org/jira/browse/WICKET-1148
> WICKET-1148 )
> --
> View this message in context: http://www.nabble.com/TreeModel-error-tf4788794.html#a13699743
>
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: TreeModel error
Posted by Doug Leeper <do...@yahoo.com>.
JIRA issue created ( http://issues.apache.org/jira/browse/WICKET-1148
WICKET-1148 )
--
View this message in context: http://www.nabble.com/TreeModel-error-tf4788794.html#a13699743
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: TreeModel error
Posted by Doug Leeper <do...@yahoo.com>.
Okay...after further digging I think I found the problem...the use of
Collections.EMPTY_LIST.
In AbstractTree:
private final void buildItemChildren(TreeItem item)
{
List items;
// if the node is expanded
if (isNodeExpanded((TreeNode)item.getModelObject()))
{
// build the items for children of the items' treenode.
items = buildTreeItems(nodeChildren((TreeNode)item.getModelObject()),
item.getLevel() + 1);
}
else
{
// it's not expanded, just set children to an empty list
items = Collections.EMPTY_LIST;
}
item.setChildren(items);
}
In Collections.java
private static class EmptyList
extends AbstractList
implements RandomAccess, Serializable {
// use serialVersionUID from JDK 1.2.2 for interoperability
private static final long serialVersionUID = 8842843931221139166L;
public int size() {return 0;}
public boolean contains(Object obj) {return false;}
public Object get(int index) {
throw new IndexOutOfBoundsException("Index: "+index);
}
// Preserves singleton property
private Object readResolve() {
return EMPTY_LIST;
}
}
In AbstractList.java:
public void add(int index, E element) {
throw new UnsupportedOperationException();
}
Question:
- Why use Collections.EMPTY_LIST? Why not new ArrayList(0)?
My situation is that I am building a tree dynamically and the node will not
be expanded initially because there are no child nodes. However, I
dynamically add child nodes to the unexpanded node which causes this error.
- Doug
--
View this message in context: http://www.nabble.com/TreeModel-error-tf4788794.html#a13699709
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org