Page 1 of 1

cancel event order

PostPosted: Tue Nov 13, 2018 10:31 am
by JuFi
Hi,
I'am using eventBeforeRowSelect to check some conditions before the other row is actually selected. Is there a possibility to stop selecting the row? For example if a condition is false I don't want to switch to a different row - so I would like to stop the event order.

Thanks in advance.

Re: cancel event order

PostPosted: Tue Nov 13, 2018 10:58 am
by Support@SIB
Simply throw an Exception to show the error dialog or throw a SilentAbortException to hide the dialog.

Re: cancel event order

PostPosted: Tue Nov 13, 2018 11:43 am
by JuFi
I tried to throw a SilentAbortException, but then I get this behaviour:

If I try to change rows for the first time and my condition is not met, I throw the SilentAbortException.
On second try my condition is met, but I seem to not get any row change events anymore.

Re: cancel event order

PostPosted: Tue Nov 13, 2018 2:02 pm
by Support@SIB
Here's the documentation about DataBook events.

Re: cancel event order

PostPosted: Tue Nov 13, 2018 3:32 pm
by Development@SIB
This is a bug in the Swing Table implementation.

Re: cancel event order

PostPosted: Tue Nov 13, 2018 4:00 pm
by Development@SIB
The problem only occurs in Swing UI, with Vaadin UI everything works.

In case of Swing, you could use the workaround:

Syntax: [ Download ] [ Hide ]
if (getApplication().getLauncher().isDesktopEnvironment())
{
    UIComponent.invokeLater(new Runnable()
    {
        @Override
        public void run()
        {
            Object o = table.getUIResource().getResource();
                       
            if (o instanceof java.awt.Component)
            {
                ((Component)o).removeNotify();
                ((Component)o).addNotify();
                ((ITableControl)table.getUIResource()).notifyRepaint();
            }
        }
    });
}

throw new SilentAbortException();

But this workaround doesn't solve the problem if you double click in the table in case of SilentAbortException. The bug is already fixed and will be available in the next JVx release or in the nightly builds!