-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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!
Hi,
com.foo.SimpleLabel should extend from zk.Widget or zul.Widget, rather than zk.Object, which is not a widget component.
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.
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.
Could you pack your widget to a jar file and mail to me? (jumperchen AT zkoss DOT org)
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>
good luck
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
Have you found what is the problem? I have the same problem..
What's your problem?
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?
Asked: 2010-02-03 19:19:39 +0800
Seen: 2,009 times
Last updated: Dec 05 '11