0

Strange error when append child in new tab ZK 5.0.0 Standard (build: 10012616)

asked 2010-02-03 11:06:55 +0800

mordor gravatar image mordor
42
Dear All, I've got a strange error, when I try to append child to new panel, I'm got a null pointer.
				Tabpanel tp = new Tabpanel();
				tp.appendChild(Executions.createComponents(newTabFile, null, null));  // here is error
				mainTabbox.getTabpanels().appendChild(tp);
03.02.2010 18:45:42 org.zkoss.zk.ui.impl.UiEngineImpl handleError:1114
SEVERE: >>java.lang.NullPointerException
>>      at org.zkoss.zk.scripting.bsh.BSHInterpreter.prepareDetachedNS(BSHInterpreter.java:316)
>>      at org.zkoss.zk.scripting.bsh.BSHInterpreter.access$1200(BSHInterpreter.java:89)
>>      at org.zkoss.zk.scripting.bsh.BSHInterpreter$NSCListener.parentChanged(BSHInterpreter.java:522)
>>      at org.zkoss.zk.ui.impl.ScopeListeners.notifyParentChanged(ScopeListeners.java:108)
>>      at org.zkoss.zk.ui.impl.SimpleScope.notifyParentChanged(SimpleScope.java:107)
>>      at org.zkoss.zk.ui.AbstractComponent.setParent(AbstractComponent.java:1034)
>>      at org.zkoss.zk.ui.AbstractComponent.insertBefore(AbstractComponent.java:1155)
>>      at org.zkoss.zk.ui.AbstractComponent.appendChild(AbstractComponent.java:1213)
>>      at com.core.explorer.MainLayoutComposer.selectActiveTab(MainLayoutComposer.java:140)
>>...
tp not null and newTabFile not null it's happend after application deploy, after page refresh all work perfectly....
delete flag offensive retag edit

9 Replies

Sort by ยป oldest newest

answered 2010-02-03 23:02:33 +0800

PeterKuo gravatar image PeterKuo
481 2

For a workaround, Can you try to modify
tp.appendChild(Executions.createComponents(newTabFile, null, null))
to
(Executions.createComponents(newTabFile, tp, null)) ???

This should be a bug. Please post to bug and let us track it.
Unless spec has said root element can't be appended as child afterward, I didn't see any of this.

link publish delete flag offensive edit

answered 2010-02-04 00:34:09 +0800

samchuang gravatar image samchuang
4084 4

updated 2010-02-04 00:34:56 +0800

Hi

I have tested similar code on ZK 5.0.1, and it's working, maybe you could try to update.

<zk>
<button label="Create Tabpanel">
<attribute name="onClick"><![CDATA[
Tabpanel tp = new Tabpanel();
tp.appendChild(Executions.createComponents("hello.zul", null, null));
tabpanels.appendChild(tp);
]]>
</attribute>
</button>
<tabbox width="500px">
	<tabs>
		<tab label="tab1" />
	</tabs>
	<tabpanels id="tabpanels">
	</tabpanels>
</tabbox>
</zk>

if the exception still happened, could you provide more detail about the executing situation?

link publish delete flag offensive edit

answered 2010-02-04 04:01:14 +0800

mordor gravatar image mordor
42

updated 2010-02-04 04:04:01 +0800

Thanks PeterKuo,

This solution work perfectly (or I couldn't catch it), otherwise it's create new component and couldn't append it :(
What I should do to post a bug?

samchuang,
I do it in java class (not in zul code) which is controller.

ZUL:
<borderlayout id="main"	apply="com.core.explorer.MainLayoutComposer">

JAVA:
public class MainLayoutComposer extends GenericForwardComposer implements ComposerExt

A little bit later i check it with last freshly build.

link publish delete flag offensive edit

answered 2010-02-04 05:16:39 +0800

PeterKuo gravatar image PeterKuo
481 2

@mordor
In the upper right portion of forum layout, we have a "Bugs" link.
It will redirect you to sourceforge to report bug.

link publish delete flag offensive edit

answered 2010-02-04 06:38:20 +0800

mordor gravatar image mordor
42

updated 2010-02-04 09:46:56 +0800

@PeterKuo

It's work perfectly, but with small bug, it's didn't bind data to combobox, I think there is a problem, when it's try to bind data to component.

Executions.createComponents(newTabFile, tp, null); // didn't bind data.

Tabpanel tp = new Tabpanel();
tp.appendChild(Executions.createComponents(newTabFile, null, null));  // Bind data

I've create bug. But if need a little bit more information, pls, write me email ;)

Link to bug. P.S. Read comments!

link publish delete flag offensive edit

answered 2010-02-05 03:49:08 +0800

mordor gravatar image mordor
42

@samchuang

With version 5.0.1 the same :) but in version 3.6.3 all work perfectly :)

link publish delete flag offensive edit

answered 2010-02-05 03:58:30 +0800

samchuang gravatar image samchuang
4084 4

updated 2010-02-05 04:00:57 +0800

Hi

the bug is there. thanks for your test~~

maybe you have some special behavior that will cause the problem. because, in my zul test, it also use Java and the same code in your java

Tabpanel tp = new Tabpanel();
tp.appendChild(Executions.createComponents("hello.zul", null, null));
tabpanels.appendChild(tp);

link publish delete flag offensive edit

answered 2010-02-05 05:32:37 +0800

mordor gravatar image mordor
42

A little bit later, I upload sources to bug truck.

link publish delete flag offensive edit

answered 2010-02-09 03:46:29 +0800

mordor gravatar image mordor
42

Fixed!
Has BeanShell attribute, NPE when change to detached parent.
A lot of thanks to tomyeh. :)

Now all work perfectly!!!

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-02-03 11:06:55 +0800

Seen: 883 times

Last updated: Feb 09 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More