0

Script for override onOpen event of bandbox

asked 2021-03-11 18:07:09 +0800

softteam gravatar image softteam
120 8

updated 2021-03-18 12:03:27 +0800

cor3000 gravatar image cor3000
5833 2 7
ZK Team

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

delete flag offensive retag edit

5 Answers

Sort by ยป oldest newest most voted
0

answered 2021-03-15 10:00:02 +0800

MDuchemin gravatar image MDuchemin
1891 1 5
ZK Team

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.

link publish delete flag offensive edit
0

answered 2021-03-15 18:28:06 +0800

softteam gravatar image softteam
120 8

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

link publish delete flag offensive edit
0

answered 2021-03-18 11:56:56 +0800

cor3000 gravatar image cor3000
5833 2 7
ZK Team

updated 2021-03-19 10:13:07 +0800

I updated the example to cover the described behavior:

  • suppress onOpen
  • send onCustom instead
  • open the bandbox from server (don't open it immediately at client side, before the event)

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

link publish delete flag offensive edit
0

answered 2021-03-18 22:46:22 +0800

softteam gravatar image softteam
120 8

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

link publish delete flag offensive edit

Comments

yes it is possible - see updated response above

cor3000 ( 2021-03-19 10:04:03 +0800 )edit
0

answered 2021-03-22 17:23:55 +0800

softteam gravatar image softteam
120 8

Thank you, this is what I needed!

Javier

link publish delete flag offensive edit
Your answer
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
2 followers

RSS

Stats

Asked: 2021-03-11 18:07:09 +0800

Seen: 20 times

Last updated: Mar 22

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