0

Radiogroup before check complete event, is it possible?

asked 2009-11-12 07:04:44 +0800

fmcypriano gravatar image fmcypriano
612 1 7
http://felipecypriano.com...

Hello,

I need an event that runs before the onCheck on radiogroup because when the users changes his already made selection I want to warn him that this change will affect his work somehow and I'll show a messagebox asking him if he is sure of what his is doing.

Is there an event to do this?


Regards

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2009-11-12 08:08:11 +0800

fmcypriano gravatar image fmcypriano
612 1 7
http://felipecypriano.com...

For now the radiogroup only have 2 radios and I manage to solve the issue with onCheck, see:

    public void onCheck_radio(CheckEvent event) {
        if (pedidoVendaFacade.current.itens) {
            def opcao = Messagebox.show("are you sure? it will remove data", "", Messagebox.YES | Messagebox.NO, Messagebox.QUESTION);
            if (opcao == Messagebox.YES) {
                pedidoVendaFacade.current.removeAllItens()
                reloadItens()
            } else {
                radio.selectedIndex = radio.selectedIndex == 0 ? 1 : 0;
            }
        }
    }

I don't think this is a good solution, we should have an event that allow us to make pre-process and to cancel if needed, for example:

public onChecking_radio(Event event) {
    // ask the user if his is sure
    if (notSure) {
        cancelChecking();
    }
}

link publish delete flag offensive edit

answered 2009-11-12 13:52:25 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2009-11-12 13:53:33 +0800

Hmmmm, i think in this case i would do it like you.

An additionally event like you shows ( onChecking() event ) needs the logic for cancelChecking()
who will stop the chain to go further to the the onCheck() event. From the lines of code it's nearly the same.

Or the component must be extended: event.getTarget().cancelChecking();
Interessting to know what the zkTeam think about that.

best
Stephan

link publish delete flag offensive edit

answered 2009-11-16 04:18:00 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

updated 2009-11-16 04:19:43 +0800

The current data flow and implementation is

1. browser change radio status and visual presentation.
2. ZK client engine was called that the status of the radio changed, and send the onCheck command back to server as an Ajax Request.
3. server receive the command and change the server side radio component status and post onCheck event to the radiogroup component.
4. applciation event listener do its job.

So it shall be the way you have done.

link publish delete flag offensive edit

answered 2016-03-25 16:55:23 +0800

mansari gravatar image mansari
1

I know this post is really old. Is there a best way to cancel checking using a zk event?

link publish delete flag offensive edit

answered 2016-05-13 07:39:03 +0800

MDuchemin gravatar image MDuchemin
1336 1 4
ZK Team

updated 2016-05-13 07:40:23 +0800

Hi Mansari,

You can register client side event listener on a "onClick" or "onMouseDown" event and event.stop will stop the event.

You can implement some javascript logic, either directly or in a function. for a simple example:

<zk>
    <radiogroup xmlns:w="client">
        <radio label="test1"/>
        <radio w:onClick="if(!window.confirm('Are you sure?')){event.stop();}" label="test2"/>
    </radiogroup>
</zk>

This will happen on Client side directly.

Regards

Update: You can also register these widget listeners from a composer or a renderer if you are creating components from java, and not a zul file.

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: 2009-11-12 07:04:44 +0800

Seen: 474 times

Last updated: May 13 '16

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