-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I had a custom control working in 3.0 which doesn't work in 3.5. It was similar to the old button.dsp and was using z.type="zul.widget.Button". After switching to 3.5.1, I got a popup box on page load stating "Failed to invoke zkButton.onSize Object required" and the onClick event doesn't fire anymore. I got the popup box error to go away by setting z.type="zul.widget.Button2", but the onClick still didn't work. I looked into button2.dsp and saw that it was using z.type="zul.btn.Button". So I tried this but then the popup box came back with the same error message and the onClick still doesn't work. Note that my pages with the regular zk button (not my custom button) works just fine. Any help would be much appreciated.
Thanks, Dao
Hi,
Did you make sure whether your JS file works or not?
If you could provide some code, that would be great.
it is correct using z.type="zul.btn.Button"
but in zk 3.5.*, we refine the javascript of button,
it fire zkButton.onup instead of zkButton.onclick
following are event handles on ZK 3.5 button
//direct to zkau zk.listen(box, "click", zkau.onclick); zk.listen(box, "dblclick", zkau.ondblclick); //zkButton Object zk.listen(btn, "focus", zkButton.onfocus); zk.listen(btn, "blur", zkButton.onblur); zk.listen(box, "mousedown", zkButton.ondown); zk.listen(box, "mouseup", zkButton.onup); zk.listen(box, "mouseover", zkButton.onover); zk.listen(box, "mouseout", zkButton.onout);
Thanks for the replies!
Well, I tried both onClick and onUp on <button> (zk's regular button) and <extbutton> (my custom button). My results as follows:
1. ZK button onClick - works
2. ZK button onUp - does not fire
3. ZK button onup (everything lower case) - org.zkoss.zk.ui.metainfo.PropertyNotFoundException: Method, setOnup, not found for class org.zkoss.zul.Button
4. custom button onClick - does not fire
5. custom button onUp - does not fire
6. custom button onup (everything lower case) - same PropertyNotFoundException
I am not overriding any functionality or events - i.e. no custom javascript file.
Source code for extbutton.dsp:
<%@ taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c" %> <c:set var="self" value="${requestScope.arg.self}"/> <table border="0" cellpadding="0" cellspacing="0" onmousedown="this.className='extBtnAct'" onmouseup="this.className='extBtnFoc'" onmouseover="this.className='extBtnFoc'" onmouseout="this.className='extBtn'" class="extBtn" id="${self.uuid}" z.type="zul.btn.Button" ${self.outerAttrs}${self.innerAttrs}> <tr> <td class="tlb" /> <td class="tmb" /> <td class="trb" /> </tr> <tr> <td class="mlb" /> <td nowrap="true" class="lbl" > <table border="0" cellpadding="0" cellspacing="0" class="ct"> <tr> <c:if test="${self.imageAssigned}"> <td><image class="ctImg" src="${c:encodeURL(self.image)}" /></td> </c:if> <c:if test="$"> <td>${self.label}</td> </c:if> </tr> </table> </td> <td class="mrb" /> </tr> <tr> <td class="blb" /> <td class="bmb" /> <td class="brb" /> </tr> </table>
testPage.zul:
<?page title="Test Page for zk components"?> <div sclass="mainArea" width="100%" xmlns:h="http://www.w3.org/1999/xhtml"> <style src="css/ext.css" /> <style src="/css/mainStyle.css" /> <style src="/css/extButton.css" /> <zscript><![CDATA[ showMsg(Button x) { String msg = x.getLabel() + " - event fired"; alert(msg); } ]]></zscript> <div sclass="btnBox"> <button label="ZK button onClick" onClick="showMsg(self)" /> <button label="ZK button onUp" onUp="showMsg(self)" /> </div> <separator/> <div sclass="btnBox"> <extbutton label="custom button onClick" onClick="showMsg(self)" /> <extbutton label="custom button onUp" onUp="showMsg(self)" /> </div> </div>
I also tried this with the onClick='alert("event fired")' to make sure it wasn't any control id or parameter passing issue. It wasn't; I get the same results. Any other ideas? Thanks.
Hi,
If you changed the structure of button.dsp, you should also implement the JS file.
Because the JS file will depend on its structure to do some different behavior.
And the onup event only exists in client side, not an event of Button component.
So the .js file is tied to the .dsp file... Well, I implement my customizations (just visual things) into the new button2.dsp instead. So I didn't have to write my own .js file and/or lose any features/bug fixes of the new zk button. Thanks for all your help. D
Asked: 2008-10-23 21:37:12 +0800
Seen: 1,371 times
Last updated: Oct 29 '08