1

I'm trying to add nodes dynamically to an Extension Library Accordion control. The whole idea is to build a menu with its options being brought from a view (view entries). I started with a very basic logic which I got from here (thanks to this guy Kraeven X BTW). I declared a variable of type accordion, and then created a new instance of BasicContainerNode, and BasicLeafNode. Everything worked fine, I was able to add the the BasicLeafNode as a child of the BasicContainerNode and set the labels for both. The problem started when I tried to add the newly created node (and its child) to my accordion control using the addNode(ITreeNode node) method. The page crashes with an Error 500 (HTTP Web Server: Command Not Handled Exception).

Any Ideas why the addNode(ITreeNode node) method ain't working?? What am I doing wrong???

Here's the SSJS code in my afterPageLoad:

   try{

    var newContainer:com.ibm.xsp.extlib.tree.impl.BasicContainerTreeNode = new com.ibm.xsp.extlib.tree.impl.BasicContainerTreeNode();
    newContainer.setLabel("Dynamic Container Node");
    var newNode:com.ibm.xsp.extlib.tree.impl.BasicLeafTreeNode = new com.ibm.xsp.extlib.tree.impl.BasicLeafTreeNode();
    newNode.setHref("http://www.google.com");
    newNode.setLabel("Dynamic Basic Node");
    newContainer.addChild(newNode);
    var acc = getComponent("accordion1");
    acc.addNode(newContainer);
}catch(e){
    print(e.toString);
}

Thanks in advance for any help.

:)

Stephen Docy
  • 4,738
  • 7
  • 18
  • 31
F Gallegos
  • 11
  • 1

1 Answers1

1

Your code works well.

Look for some other issue on your XPage. Activate "Display XPage runtime error page" or look at the log file on server to find out what causes the error.

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
  • Hi Knut, thanks for replying and giving me such a hint, sorry I forgot to mention that I'm running the app locally and using web preview. However, I was able to activate "Display XPage runtime error page" and look at the log file at my IBM Technical Support folder as well. This is what I got: **Page Name: /testmenu.xsp java.lang.ClassCastException: com.ibm.xsp.extlib.tree.impl.BasicContainerTreeNode incompatible with javax.faces.component.StateHolder** – F Gallegos Jul 12 '17 at 10:53