DBTreeView Exception

Hi All,
I am using DBTreeView Bean in one of my sample solution in Servoy 4.0. In this solutions what i am doing, first initializing the tree then after that i am adding multiple nodes under parent node. but when i doing the same it is giving me following execption.

Wrapped java.lang.NullPointerException (D:\Servoy WorkSpace\TreeBeanSample\forms\Test\Test_methods.js#18)
> java.lang.NullPointerException

Here is my Code.

Form Method
function addNode()

{

controller.loadAllRecords();

controller.newRecord(true);

node_id = 100;

label_text = “New Test Node 1”;

parent_id = 2;

controller.loadAllRecords(); //This is the line 18 where it is returning the exception

controller.newRecord(true);

node_id = 101;

label_text = “New Test Node 2”;

parent_id = 2;

databaseManager.saveData();

elements.company_tree.refresh();

}

function onShow()

{

var _binding = elements.company_tree.createBinding(controller.getServerName(), controller.getTableName());

_binding.setNRelationName(‘node_to_node’);

_binding.setTextDataprovider(‘label_text’);

_binding.setMethodToCallOnClick(globals.onNodeClick, ‘label_text’);

controller.find();

parent_id = 0;

controller.search(true,true);

elements.company_tree.addRoots(foundset);

}

Please telling my it is giving me error.

Thanks
Prem

When you get nullPointer errors, it usually means you encountered an issue in Servoy.

Can you post the entire error message, taken from the log file of Servoy?

Paul

Hi Paul,
Thanks for reply…

Servoy Log Entry

2008-08-14 11:09:48,224 ERROR [AWT-EventQueue-0] com.servoy.j2db.util.Debug - Throwable
org.mozilla.javascript.WrappedException: Wrapped java.lang.NullPointerException (D:\Servoy WorkSpace\TreeBeanSample\forms\Test\Test_methods.js#18)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1828)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:199)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:341)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3679)
at script.addNode(D:\Servoy WorkSpace\TreeBeanSample\forms\Test\Test_methods.js:18)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2680)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:166)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:387)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3095)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:165)
at com.servoy.j2db.scripting.RemoteDebugScriptEngine.executeFunction(Unknown Source)
at com.servoy.j2db.FormController.a(Unknown Source)
at com.servoy.j2db.FormController.executeFunction(Unknown Source)
at com.servoy.j2db.FormController.actionPerformed(Unknown Source)
at com.servoy.j2db.FormController$a.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at javax.swing.plaf.basic.BasicTreeUI$Handler.treeNodesChanged(Unknown Source)
at javax.swing.tree.DefaultTreeModel.fireTreeNodesChanged(Unknown Source)
at javax.swing.tree.DefaultTreeModel.nodesChanged(Unknown Source)
at javax.swing.tree.DefaultTreeModel.nodeChanged(Unknown Source)
at com.servoy.extensions.beans.dbtreeview.SwingDBTreeView.tableChanged(SwingDBTreeView.java:993)
at com.servoy.j2db.dataprocessing.w.fireTableModelEvent(Unknown Source)
at com.servoy.j2db.dataprocessing.w$2.run(Unknown Source)
at com.servoy.j2db.dataprocessing.w.a(Unknown Source)
at com.servoy.j2db.dataprocessing.EditRecordList.fireEvents(Unknown Source)
at com.servoy.j2db.dataprocessing.EditRecordList.a(Unknown Source)
at com.servoy.j2db.dataprocessing.EditRecordList.stopEditing(Unknown Source)
at com.servoy.j2db.dataprocessing.JSDatabaseManager.js_saveData(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:179)
… 37 more

Thanks
Prem

the exception is on saveData()
but the real nullpointer is not in our code but in the UI code of swing itself.
If could be that something is wrong in the data that is in the tree’s model.

Can you make a case with that sample solution?

I have made case on servoy support. this is the case id - 154212.

Thanks
Prem

I think this error always happens when you add nodes to the root of the tree (on the top level). But it doesn’t interrupt anything in my case and the tree actually works.

patrick:
I think this error always happens when you add nodes to the root of the tree (on the top level). But it doesn’t interrupt anything in my case and the tree actually works

No, Patrick I am adding node at child level not on top level. I am attaching a sample solution. May be i am committing mistake. Please check this attached solution and Please guide me how to remove this error.

Thanks
Prem

SampleDBTree.servoy (6.66 KB)

issue is fixed in the next release