-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I would like to have a script that overrides onOpen event in Bandbox in order to open this bandbox via controller in a custom event. I tried to do this in my zul page but this does not work. How can I do it? What I have is this:
script><![CDATA[
zk.afterLoad("zul.bandbox", function () {
var _xBandbox = {};
zk.override(zul.bandbox.Bandbox.prototype, _xBandbox, {
doClick_: function() {
this.fire("onCustom", open: !this._open, {toServer:true});
}
});
});
]]></script>
Thank you, Javier
Hi Javier,
The general idea is right, but some of the details need to be updated. See a zkfiddle sample here: https://zkfiddle.org/sample/2qmuud5/1-combobox-override
Keep in mind that the Java package declaration (of the Java component class) and the JS package declaration (of the JS widget class) are two separate things. To locate the package of a specific component, you have a few options.
You can manually check at client side using the console / JS sources or you can use the documentation such as the JS API docs..
Have a look, and let me know if this works for you.
Hi,
I used the zkfiddle sample and onCustom event fired. However, also the onOpen event fired and I only want the onCustom event to be fired.
I got this in .zul page:
<bandbox id="BBBuscador" open="false" >
And in the .java file:
public void onOpen$BBBuscador(){
//Some code
}
public void onCustom$BBBuscador(){
//Some code
}
How can I do to avoid the onOpen to be fired?
The java Class that I use is GenericForwardComposer.
Thank you, Javier
I updated the example to cover the described behavior:
https://zkfiddle.org/sample/2qmuud5/14-combobox-override
this implementation directly overrides the open()
function, doClick_
is not the correct method anyway it would have been _doBtnClick
. However that doesn't capture keyboard control (ALT-DOWN) so the central method is open
, when it receives the opts.sendOnOpen
argument, it will only send onCustom and do nothing else, so you can take over control in the composer, e.g. changing the contents of the bandpopup and then call setOpen(true)
.
Does this cover what you intended?
UPDATE 2021-03-19
you can also override the open method just for an individual bandbox:
updated fiddle: https://zkfiddle.org/sample/2qmuud5/15-combobox-override-single-component
please also read the related docs on widget customization
Hi,
This cover what I intended. However, I realised that when I open this .zul page, any Bandbox from any other .zul page do not fire the onOpen event. Is it posible to override this event only for an specific .zul page or for an specific Bandbox id?
Thank you, Javier
Asked: 2021-03-11 18:07:09 +0800
Seen: 20 times
Last updated: Mar 22 '21
zk bandbox different behaviour in ver 9.6.0.1
Creating a Custom Component (Accordion)
Sign out all desktops in a Session
ZK how to stop OnClick event of tab? [closed]
Execute Javascript on component visible
ZK Clustering, Session Replication Question [closed]