0

ZK 5 RC2/ZK 5 custom component problem

asked 2010-02-03 19:19:39 +0800

madspacer gravatar image madspacer
9 1

Hi,

I am having problem getting the example label custom component widget to work under ZK 5 RC2/ZK 5. The sample can be found on this page: http://docs.zkoss.org/wiki/A_Simple_Example:_Label

All I got is the processing screen without any errors in the log. The strange thing is it worked fine under ZK 5 RC.

Here are my files with their directory path:

/WEB-INF/home.zul (starting zul page)

<SimpleLabel value="hello world">
</SimpleLabel>

/WEB-INF/zk.xml

<zk>
<language-config>
<addon-uri>/WEB-INF/zk/lang-addon.xml</addon-uri>
</language-config>
</zk>

/WEB-INF/zk/lang-addon.xml

<language-addon>
<addon-name>com.foo</addon-name>
<language-name>xul/html</language-name>

<component>
<component-name>SimpleLabel</component-name>
<component-class>com.foo.SimpleLabel</component-class>
<widget-class>com.foo.SimpleLabel</widget-class>
<mold>
<mold-name>default</mold-name>
<mold-uri>mold/simple-label.js</mold-uri>
</mold>
</component>
</language-addon>

/src/java/web/js/com/foo/zk.wpd

<package name="com.foo" language="xul/html">
<widget name="SimpleLabel"/>
</package>

/src/java/web/js/com/foo/SimpleLabel.js

com.foo.SimpleLabel = zk.$extends(zk.Object, {
_value: '', //default value

getValue: function () {
return this._value;
},
setValue: function(value) {
if (this._value != value) {
this._value = value;
if (this.$n()) this.$n().innerHTML = zUtl.encodeXML(value);
}
}
});

/src/java/web/js/com/foo/mold/simple-label.js

function (out) {
out.push('<span', this.domAttrs_(), '>', this.getValue(), '</span>');
}

/src/java/com/foo/SimpleLabel.java

package com.foo;

public class SimpleLabel extends org.zkoss.zk.ui.HtmlBasedComponent {
private String _value = ""; //a data member

public String getValue() {
return _value;
}
public void setValue(String value) {
if (!_value.equals(value)) {
_value = value;
smartUpdate("value", _value);
}
}
protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer)
throws java.io.IOException {
super.renderProperties(renderer);
render(renderer, "value", _value);
}
}

I've must done something wrong here. Thanks in advance!

delete flag offensive retag edit

10 Replies

Sort by ยป oldest newest

answered 2010-02-04 02:38:26 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Hi,

com.foo.SimpleLabel should extend from zk.Widget or zul.Widget, rather than zk.Object, which is not a widget component.

link publish delete flag offensive edit

answered 2010-02-04 16:16:20 +0800

madspacer gravatar image madspacer
9 1

Hi Chen,

I've changed SimpleLabel to extend zk.Widget, which fixed the problem. Thanks you!

By the way the demo page has "com.foo.SimpleLabel = zk.$extends(zul.Widget" I think it needs to extend zk.Widget instead.

link publish delete flag offensive edit

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

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

I don't think so, the zul.Widget is extended from zk.Widget to provide more high level API for component developer, such as tooltip, popup, context, and so on.

link publish delete flag offensive edit

answered 2010-02-05 15:59:37 +0800

madspacer gravatar image madspacer
9 1

Thanks for clarify that Chen.

But for some reason ZK always stuck at loading screen if I made the SimpleLabel extends zul.Widget. changing to zk.Widget fixes the problem.

link publish delete flag offensive edit

answered 2010-02-06 03:23:05 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Could you pack your widget to a jar file and mail to me? (jumperchen AT zkoss DOT org)

link publish delete flag offensive edit

answered 2010-02-12 17:05:09 +0800

aktejo gravatar image aktejo
155 3

updated 2010-02-12 17:08:03 +0800

processing busy alert,.. hmm, i have had such experience too, i think the problem is in your zk.wpd file. zk developer has just change the spesification.
modify your zk.wpd into:

<package name="com.foo" language="xul/html" depends="zul">
	<widget name="SimpleLabel"/>
</package>

(add depends="zul")
just take a look on this thread for complete solution
thread about zk.wpd problem

good luck

link publish delete flag offensive edit

answered 2010-06-24 09:17:14 +0800

farmacia gravatar image farmacia
105

I had the same effect on a page.

I found out it was a NULL in in the setParent() method. That made my page loading and loading and loading and loading and loading .....etc. without any error, it just never finished the process.

Because of the Thread-Date maybe you already fixed it.

greedings,

Patrick

link publish delete flag offensive edit

answered 2010-08-29 08:05:02 +0800

fabou3377 gravatar image fabou3377
60 1

updated 2010-08-29 08:38:23 +0800

Have you found what is the problem? I have the same problem..

link publish delete flag offensive edit

answered 2010-09-01 21:15:51 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

What's your problem?

link publish delete flag offensive edit

answered 2011-12-05 18:51:07 +0800

UmbraNoctis gravatar image UmbraNoctis
9

I'm having the same problem, it's stuck at the processing alert.
My code is pretty much the same as the one originally posted here, but instead of SimpleLabel it's called keylistener (I'm trying to adapt the keylistener component to zk 5.0)

I've tried switching to zul.Widget, zk.Widget, using no mold (redraw) a mold... nothing works..
added the depend="zul" line,
and also debugged and checked that the setparent method doesn't receive null as parameter...

anyone able to help?

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 19:19:39 +0800

Seen: 2,009 times

Last updated: Dec 05 '11

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