Hi Rolf,

ITreeNode.getChild(index) method is called from ITreeModel.getChild(parent,
index) which is called by ULCTree.

In your model you should make sure that getChildCount() is correct.

Also you must make sure that you have not added any "null" nodes to a
parent.

I hope this helps.

Thanks and regards,

Janak

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: Friday, August 04, 2006 1:22 PM
To: [EMAIL PROTECTED] Com
Subject: Antwort: RE: Antwort: RE: [ULC-developer] Problem with ULCTree



Hi Janak.
sorry for insisting, but my problem is not solved.
ITreeNode.getChild(index) is implemented by me and is called by ULCTree. My
implementation must assure that only valid ITreeNodes are returned by the
method. But what should my method do, if it is called with an invalid index
? The usual way is to return null - resulting in the IllegalStateException.
So I did some logging:
    public ITreeNode getChildAt(int pos) {
            if (children != null) {
                    if (pos < children.size())
                            return (ITreeNode) children.get(pos);
                    else {
                            logger.fine("TreePath=" + getPath().toString() +
" getChildAt is called with Index " + pos + ", getChildCount() = " +
getChildCount());
//                            return null;
                            return (ITreeNode)
children.get(children.size()-1);    // NO MORE EXCEPTIONS, BUT THIS IS WRONG
!!!
                    }
            }
            else {
                        logger.fine("null Children2 " + pos + " " +
this.toString());
                        return null;
            }
    }
    public int getChildCount() {
                if (children != null)
                        return children.size();
                else
                        return 0;
    }

When I collapse the first node the result of the logging is:  (the
ChildCount 9 is correct)

DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 9, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 10, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 11, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 12, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 13, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 14, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 15, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 16, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 17, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 18, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 19, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 20, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 21, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 22, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 23, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 24, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 25, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 26, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 9, getChildCount() = 9
DEBUG 09:29:53,533 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 10, getChildCount() = 9
DEBUG 09:29:53,543 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 11, getChildCount() = 9
DEBUG 09:29:53,543 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 12, getChildCount() = 9
DEBUG 09:29:53,543 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 13, getChildCount() = 9
DEBUG 09:29:53,543 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 14, getChildCount() = 9
DEBUG 09:29:53,543 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 15, getChildCount() = 9
DEBUG 09:29:53,543 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 16, getChildCount() = 9
DEBUG 09:29:53,543 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 17, getChildCount() = 9
DEBUG 09:29:53,543 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 18, getChildCount() = 9
DEBUG 09:29:53,543 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 19, getChildCount() = 9
DEBUG 09:29:53,543 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 20, getChildCount() = 9
DEBUG 09:29:53,543 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 21, getChildCount() = 9
DEBUG 09:29:53,543 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 22, getChildCount() = 9
DEBUG 09:29:53,543 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 23, getChildCount() = 9
DEBUG 09:29:53,543 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 24, getChildCount() = 9
DEBUG 09:29:53,543 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 25, getChildCount() = 9
DEBUG 09:29:53,543 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 26, getChildCount() = 9

When I take the slider bar to go to the end of the tree the result of the
logging is
DEBUG 09:43:56,275 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 9, getChildCount() = 9
DEBUG 09:43:56,275 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 10, getChildCount() = 9
DEBUG 09:43:56,275 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 11, getChildCount() = 9
DEBUG 09:43:56,275 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 12, getChildCount() = 9
DEBUG 09:43:56,275 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 9, getChildCount() = 9
DEBUG 09:43:56,275 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 10, getChildCount() = 9
DEBUG 09:43:56,275 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 11, getChildCount() = 9
DEBUG 09:43:56,275 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 12, getChildCount() = 9
DEBUG 09:43:56,315 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 13, getChildCount() = 9
DEBUG 09:43:56,315 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 14, getChildCount() = 9
DEBUG 09:43:56,315 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 15, getChildCount() = 9
         ......
DEBUG 09:43:57,357 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 125, getChildCount() = 9
DEBUG 09:43:57,357 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 126, getChildCount() = 9
DEBUG 09:43:57,357 base.view.MutableTreeNode - TreePath=[Root] getChildAt is
called with Index 127, getChildCount() = 9

Mit freundlichen Grüßen
Rolf Gadorosi
_____________________________________________
weisser + böhle GmbH
Schwieberdinger Str. 52
71636 Ludwigsburg

Tel:        +49 7141 4765 18
Fax:        +49 7141 4765 22
Mobil:        +49 162 2521018
Email:        [EMAIL PROTECTED]
"Janak Mulani" <[EMAIL PROTECTED]> schrieb am 03.08.2006 18:14:48:

> Hi Rolf,
>
> I had to dig in the old code to answer your question.
>
> The change has been done in  getPathForDescription(int[] description)
>
> wheren if getChild(parent, index) returns null then the following
exception
> is thrown:
>
>                 IllegalStateException("ITreeModel.getChild(Object parent,
> int index) must not return " +
>                         "null for valid indices (parent=" + parent + ",
> index=" + index + ")");
>
>
> So the answer to your question is No.
>
> ITreeNode.getChild(index) is an interface method which will be implemented
> by the devlopers so ULC can't really guarantee the value of index.
>
> I hope this helps.
>
> Thanks and regards,
>
> Janak
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 02, 2006 6:24 PM
> To: [EMAIL PROTECTED]
> Subject: Antwort: RE: [ULC-developer] Problem with ULCTree
>
>
>
> Hi Janak,
> thanks for your hint.
> I found that issue in your database, and after that I found out that my
> method getChild(int index) for the root node is called with an index
greater
> than the child count and that was the cause of my problem. In other
> situations the method was not called for all children, resulting in a
> smaller ULCTree than provided by the model.
> I don't understand the header and the description in that issue in a way
> that the method getChild(int index) will no more be called with an index
> greater than the child count. Is my understanding wrong ?
> Will the method be called for exactly the right number of children
starting
> with ULC 6.0.3 ?
>
> A "Yes" as an answer is sufficient .... :)
> Mit freundlichen Grüßen
> Rolf Gadorosi
> _____________________________________________
> weisser + böhle GmbH
> Schwieberdinger Str. 52
> 71636 Ludwigsburg
>
> Tel:        +49 7141 4765 18
> Fax:        +49 7141 4765 22
> Mobil:        +49 162 2521018
> Email:        [EMAIL PROTECTED]
> "Janak Mulani" <[EMAIL PROTECTED]> schrieb am 02.08.2006 14:27:15:
>
> > Hi Rolf,
> >
> > Your ITreeModel implementation seems to return null from a call to
> > ITreeModel.getChild(Object parent, int index). This leads to the given
> > exception later on. There is already an issue in our issue database:
> > https://www.canoo.com/jira/browse/UBA-1096 which has been fixed in ULC
> > 6.0.3.
> >
> > Thanks and regards,
> >
> > Janak
> >
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] Behalf Of
> > [EMAIL PROTECTED]
> > Sent: Tuesday, August 01, 2006 12:56 PM
> > To: [email protected]
> > Subject: [ULC-developer] Problem with ULCTree
> >
> >
> >
> > Hi together,
> > I am building a ULCTree with the DefaultTreeModel based upon
> > MutableTreeNodes.
> > The model is completely built and the program can walk through all the
> > nodes.
> > When the DefaultTreeModel is connected to the ULCTree, there are about
70
> > nodes that are expanded and the first one is selected. Everything seems
to
> > work fine. But when I collapse that expanded node I get the following
> > Exception.
> > I get the same Exception when I try to show the lower parts of the
ULCTree
> > by the slider bar.
> > I get the same Exception when I try to show the lower parts of the
ULCTree
> > by the "Down Arrow Key" or by the "Page Down Key".
> > These Exceptions are thrown at different nodes of the tree, so I think
it
> is
> > not a problem with the content or the structure of a special node.
> > There are about 7000 nodes in the complete tree and I am using ULC
> 6.0.1.1.
> > Can you give me a hint ?
> > Thanks & regards
> > Rolf Gadorosi
> > java.lang.NullPointerException: Null child not allowed
> >         at
> >
>
com.ulcjava.base.application.tree.TreePath.pathByAddingChild(TreePath.java:1
> > )
> >         at
> >
>
com.ulcjava.base.server.ULCTreeModelAdapter.getPathForDescription(ULCTreeMod
> > elAdapter.java:20)
> >         at
> >
com.ulcjava.base.server.ULCTreeModelAdapter.c(ULCTreeModelAdapter.java:61)
> >         at
> >
>
com.ulcjava.base.server.ULCTreeModelAdapter.handleRequest(ULCTreeModelAdapte
> > r.java:29)
> >         at com.ulcjava.base.server.ULCSession.a(ULCSession.java:163)
> >         at
> > com.ulcjava.base.server.ULCSession.processRequests(ULCSession.java:0)
> >         at
> >
>
com.ulcjava.base.development.DevelopmentContainerAdapter.processRequests(Dev
> > elopmentContainerAdapter.java:17)
> >         at
> >
>
com.ulcjava.base.development.DevelopmentConnector.sendRequests(DevelopmentCo
> > nnector.java:14)
> >         at
com.ulcjava.base.client.UISession$j_.run(UISession$j_.java:26)
> >         at java.lang.Thread.run(Unknown Source)
> >
>

_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to