You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Daniel Stoch <da...@gmail.com> on 2014/06/17 15:55:48 UTC

How to handle click on disabled links - ListenerInvocationNotAllowedException?

Hi,

I have a link (or ajax link) which executes some system command. This
system gives me an information if this command is enabled or not, so I
can mark my link as enabled or disabled (by calling
setEnabled(command.isEnabled()) or overriding link.isEnabled()
method).

1. Page is being rendered, command is enabled so link is rendered as enabled.
2. In the meantime system state is changed so command became disabled.
3. User clicks link on a page rendered in step 1 where link is
rendered as enabled but it is disabled now.

In Wicket 1.4 nothing happens in such situation and only warning was logged:
"component not enabled or visible; ignoring call. Component:
[MarkupContainer [Component id = link]]"

In Wicket 6 in such situation the exception is raised:
"ListenerInvocationNotAllowedException: Behavior rejected interface invocation."

How should I handle this correctly to show some information to user,
that this is link is no longer active (but user should stay on the
same page)?
Should I catch ListenerInvocationNotAllowedException inside
IRequestCycleListener.onException()?

--
Daniel

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to handle click on disabled links - ListenerInvocationNotAllowedException?

Posted by Martin Grigorov <mg...@apache.org>.
On Tue, Jun 17, 2014 at 5:26 PM, Daniel Stoch <da...@gmail.com>
wrote:

> On Tue, Jun 17, 2014 at 4:00 PM, Martin Grigorov <mg...@apache.org>
> wrote:
> > Hi,
> >
> >
> > On Tue, Jun 17, 2014 at 4:55 PM, Daniel Stoch <da...@gmail.com>
> > wrote:
> >
> >> Hi,
> >>
> >> I have a link (or ajax link) which executes some system command. This
> >> system gives me an information if this command is enabled or not, so I
> >> can mark my link as enabled or disabled (by calling
> >> setEnabled(command.isEnabled()) or overriding link.isEnabled()
> >> method).
> >>
> >> 1. Page is being rendered, command is enabled so link is rendered as
> >> enabled.
> >> 2. In the meantime system state is changed so command became disabled.
> >> 3. User clicks link on a page rendered in step 1 where link is
> >> rendered as enabled but it is disabled now.
> >>
> >> In Wicket 1.4 nothing happens in such situation and only warning was
> >> logged:
> >> "component not enabled or visible; ignoring call. Component:
> >> [MarkupContainer [Component id = link]]"
> >>
> >> In Wicket 6 in such situation the exception is raised:
> >> "ListenerInvocationNotAllowedException: Behavior rejected interface
> >> invocation."
> >>
> >> How should I handle this correctly to show some information to user,
> >> that this is link is no longer active (but user should stay on the
> >> same page)?
> >> Should I catch ListenerInvocationNotAllowedException inside
> >> IRequestCycleListener.onException()?
> >>
> >
> > Yes. This is the best you can do in this case.
> >
>
> Thanks for very fast answer :)
> But what should I return as a IRequestHandler in
> IRequestCycleListener.onException()? I can return EmptyRequestHandler
> to silently catch an exception, but if I want show some info to user
> then...?
>


page.warning(...); // see
PageRequestHandlerTracker#getFirstHandler(cycle).getPage();
AjaxRequestTarget target = requestCycle.find(AjaxRequestTarget.class);
if (target != null) {
  target.addChildren(page, IFeedback.class);
  return target;
} else {
  return new RenderPageRequestHandler(new PageProvider(page));
}


>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How to handle click on disabled links - ListenerInvocationNotAllowedException?

Posted by Daniel Stoch <da...@gmail.com>.
On Tue, Jun 17, 2014 at 4:00 PM, Martin Grigorov <mg...@apache.org> wrote:
> Hi,
>
>
> On Tue, Jun 17, 2014 at 4:55 PM, Daniel Stoch <da...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I have a link (or ajax link) which executes some system command. This
>> system gives me an information if this command is enabled or not, so I
>> can mark my link as enabled or disabled (by calling
>> setEnabled(command.isEnabled()) or overriding link.isEnabled()
>> method).
>>
>> 1. Page is being rendered, command is enabled so link is rendered as
>> enabled.
>> 2. In the meantime system state is changed so command became disabled.
>> 3. User clicks link on a page rendered in step 1 where link is
>> rendered as enabled but it is disabled now.
>>
>> In Wicket 1.4 nothing happens in such situation and only warning was
>> logged:
>> "component not enabled or visible; ignoring call. Component:
>> [MarkupContainer [Component id = link]]"
>>
>> In Wicket 6 in such situation the exception is raised:
>> "ListenerInvocationNotAllowedException: Behavior rejected interface
>> invocation."
>>
>> How should I handle this correctly to show some information to user,
>> that this is link is no longer active (but user should stay on the
>> same page)?
>> Should I catch ListenerInvocationNotAllowedException inside
>> IRequestCycleListener.onException()?
>>
>
> Yes. This is the best you can do in this case.
>

Thanks for very fast answer :)
But what should I return as a IRequestHandler in
IRequestCycleListener.onException()? I can return EmptyRequestHandler
to silently catch an exception, but if I want show some info to user
then...?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to handle click on disabled links - ListenerInvocationNotAllowedException?

Posted by Martin Grigorov <mg...@apache.org>.
Hi,


On Tue, Jun 17, 2014 at 4:55 PM, Daniel Stoch <da...@gmail.com>
wrote:

> Hi,
>
> I have a link (or ajax link) which executes some system command. This
> system gives me an information if this command is enabled or not, so I
> can mark my link as enabled or disabled (by calling
> setEnabled(command.isEnabled()) or overriding link.isEnabled()
> method).
>
> 1. Page is being rendered, command is enabled so link is rendered as
> enabled.
> 2. In the meantime system state is changed so command became disabled.
> 3. User clicks link on a page rendered in step 1 where link is
> rendered as enabled but it is disabled now.
>
> In Wicket 1.4 nothing happens in such situation and only warning was
> logged:
> "component not enabled or visible; ignoring call. Component:
> [MarkupContainer [Component id = link]]"
>
> In Wicket 6 in such situation the exception is raised:
> "ListenerInvocationNotAllowedException: Behavior rejected interface
> invocation."
>
> How should I handle this correctly to show some information to user,
> that this is link is no longer active (but user should stay on the
> same page)?
> Should I catch ListenerInvocationNotAllowedException inside
> IRequestCycleListener.onException()?
>

Yes. This is the best you can do in this case.


>
> --
> Daniel
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How to handle click on disabled links - ListenerInvocationNotAllowedException?

Posted by Sven Meier <sv...@meiers.net>.
Background information:

http://apache-wicket.1842946.n4.nabble.com/vote-release-Wicket-1-4-14-tp3056628p3063795.html
http://wicketinaction.com/2011/11/implement-wicket-component-visibility-changes-properly/

Sven


On 06/17/2014 05:15 PM, Daniel Stoch wrote:
> On Tue, Jun 17, 2014 at 5:08 PM, Sven Meier <sv...@meiers.net> wrote:
>> If you alter the enabled state of your links in #onConfigure(), they will
>> still be enabled - even if the server state already changed.
>>
>> Sven
> Yes, you're right!
>
> I have investigated two scenarios just before your last answer :).
> 1. Link has overriden isEnabled() - then
> ListenerInvocationNotAllowedException is when command is not (as I
> described in my first post).
> 2. The enabled state of links are altered in #onConfigure() - link is
> still enabled even if the server state already changed. So we must do
> an extra check in onClick() method.
>
> So now I try to use the second solution (I have an abstraction over
> all links so it would be easy to implement) and add an extra check
> before calling a link code.
> Thanks for your help.
>
> --
> Daniel
>
>
>>
>> On 06/17/2014 04:32 PM, Daniel Stoch wrote:
>>> On Tue, Jun 17, 2014 at 4:27 PM, Sven Meier <sv...@meiers.net> wrote:
>>>> Hi,
>>>>
>>>>
>>>>> The next click does not come because exception is raised.
>>>>
>>>> if the link is still enabled, which exception should be thrown then?
>>>>
>>>> Sven
>>>>
>>> Please read again steps 1,2,3 ;).
>>> Link is rendered as enabled in the browser (1), but on the server is
>>> not enabled anymore (3).
>>>
>>> --
>>> Daniel
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to handle click on disabled links - ListenerInvocationNotAllowedException?

Posted by Daniel Stoch <da...@gmail.com>.
On Tue, Jun 17, 2014 at 5:08 PM, Sven Meier <sv...@meiers.net> wrote:
> If you alter the enabled state of your links in #onConfigure(), they will
> still be enabled - even if the server state already changed.
>
> Sven

Yes, you're right!

I have investigated two scenarios just before your last answer :).
1. Link has overriden isEnabled() - then
ListenerInvocationNotAllowedException is when command is not (as I
described in my first post).
2. The enabled state of links are altered in #onConfigure() - link is
still enabled even if the server state already changed. So we must do
an extra check in onClick() method.

So now I try to use the second solution (I have an abstraction over
all links so it would be easy to implement) and add an extra check
before calling a link code.
Thanks for your help.

--
Daniel


>
>
> On 06/17/2014 04:32 PM, Daniel Stoch wrote:
>>
>> On Tue, Jun 17, 2014 at 4:27 PM, Sven Meier <sv...@meiers.net> wrote:
>>>
>>> Hi,
>>>
>>>
>>>> The next click does not come because exception is raised.
>>>
>>>
>>> if the link is still enabled, which exception should be thrown then?
>>>
>>> Sven
>>>
>> Please read again steps 1,2,3 ;).
>> Link is rendered as enabled in the browser (1), but on the server is
>> not enabled anymore (3).
>>
>> --
>> Daniel
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to handle click on disabled links - ListenerInvocationNotAllowedException?

Posted by Sven Meier <sv...@meiers.net>.
If you alter the enabled state of your links in #onConfigure(), they 
will still be enabled - even if the server state already changed.

Sven

On 06/17/2014 04:32 PM, Daniel Stoch wrote:
> On Tue, Jun 17, 2014 at 4:27 PM, Sven Meier <sv...@meiers.net> wrote:
>> Hi,
>>
>>
>>> The next click does not come because exception is raised.
>>
>> if the link is still enabled, which exception should be thrown then?
>>
>> Sven
>>
> Please read again steps 1,2,3 ;).
> Link is rendered as enabled in the browser (1), but on the server is
> not enabled anymore (3).
>
> --
> Daniel
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to handle click on disabled links - ListenerInvocationNotAllowedException?

Posted by Daniel Stoch <da...@gmail.com>.
On Tue, Jun 17, 2014 at 4:27 PM, Sven Meier <sv...@meiers.net> wrote:
> Hi,
>
>
>> The next click does not come because exception is raised.
>
>
> if the link is still enabled, which exception should be thrown then?
>
> Sven
>

Please read again steps 1,2,3 ;).
Link is rendered as enabled in the browser (1), but on the server is
not enabled anymore (3).

--
Daniel

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to handle click on disabled links - ListenerInvocationNotAllowedException?

Posted by Sven Meier <sv...@meiers.net>.
Hi,

> The next click does not come because exception is raised.

if the link is still enabled, which exception should be thrown then?

Sven


On 06/17/2014 04:24 PM, Daniel Stoch wrote:
> On Tue, Jun 17, 2014 at 4:14 PM, Sven Meier <sv...@meiers.net> wrote:
>> Hi,
>>
>> when you alter the enabled state in #onConfigure() - this is recommended
>> instead of overriding #isEnabled() - the link will still be enabled when the
>> next click comes in.
> Hmmm, I think I don't understand :). The next click does not come
> because exception is raised. If I catch exception and do nothing the
> link is still enabled to user, because page is not rerendered,
>
>> You can handle the changed system state in your application logic.
> How?
> The only solution I know is to auto-refresh a page (eg. using push),
> but user can always click faster ;).
>
>> Best regards
>> Sven
>>
>>
>> On 06/17/2014 03:55 PM, Daniel Stoch wrote:
>>> Hi,
>>>
>>> I have a link (or ajax link) which executes some system command. This
>>> system gives me an information if this command is enabled or not, so I
>>> can mark my link as enabled or disabled (by calling
>>> setEnabled(command.isEnabled()) or overriding link.isEnabled()
>>> method).
>>>
>>> 1. Page is being rendered, command is enabled so link is rendered as
>>> enabled.
>>> 2. In the meantime system state is changed so command became disabled.
>>> 3. User clicks link on a page rendered in step 1 where link is
>>> rendered as enabled but it is disabled now.
>>>
>>> In Wicket 1.4 nothing happens in such situation and only warning was
>>> logged:
>>> "component not enabled or visible; ignoring call. Component:
>>> [MarkupContainer [Component id = link]]"
>>>
>>> In Wicket 6 in such situation the exception is raised:
>>> "ListenerInvocationNotAllowedException: Behavior rejected interface
>>> invocation."
>>>
>>> How should I handle this correctly to show some information to user,
>>> that this is link is no longer active (but user should stay on the
>>> same page)?
>>> Should I catch ListenerInvocationNotAllowedException inside
>>> IRequestCycleListener.onException()?
>>>
>>> --
>>> Daniel
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to handle click on disabled links - ListenerInvocationNotAllowedException?

Posted by Daniel Stoch <da...@gmail.com>.
On Tue, Jun 17, 2014 at 4:14 PM, Sven Meier <sv...@meiers.net> wrote:
> Hi,
>
> when you alter the enabled state in #onConfigure() - this is recommended
> instead of overriding #isEnabled() - the link will still be enabled when the
> next click comes in.

Hmmm, I think I don't understand :). The next click does not come
because exception is raised. If I catch exception and do nothing the
link is still enabled to user, because page is not rerendered,

> You can handle the changed system state in your application logic.

How?
The only solution I know is to auto-refresh a page (eg. using push),
but user can always click faster ;).

>
> Best regards
> Sven
>
>
> On 06/17/2014 03:55 PM, Daniel Stoch wrote:
>>
>> Hi,
>>
>> I have a link (or ajax link) which executes some system command. This
>> system gives me an information if this command is enabled or not, so I
>> can mark my link as enabled or disabled (by calling
>> setEnabled(command.isEnabled()) or overriding link.isEnabled()
>> method).
>>
>> 1. Page is being rendered, command is enabled so link is rendered as
>> enabled.
>> 2. In the meantime system state is changed so command became disabled.
>> 3. User clicks link on a page rendered in step 1 where link is
>> rendered as enabled but it is disabled now.
>>
>> In Wicket 1.4 nothing happens in such situation and only warning was
>> logged:
>> "component not enabled or visible; ignoring call. Component:
>> [MarkupContainer [Component id = link]]"
>>
>> In Wicket 6 in such situation the exception is raised:
>> "ListenerInvocationNotAllowedException: Behavior rejected interface
>> invocation."
>>
>> How should I handle this correctly to show some information to user,
>> that this is link is no longer active (but user should stay on the
>> same page)?
>> Should I catch ListenerInvocationNotAllowedException inside
>> IRequestCycleListener.onException()?
>>
>> --
>> Daniel
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to handle click on disabled links - ListenerInvocationNotAllowedException?

Posted by Sven Meier <sv...@meiers.net>.
Hi,

when you alter the enabled state in #onConfigure() - this is recommended 
instead of overriding #isEnabled() - the link will still be enabled when 
the next click comes in.

You can handle the changed system state in your application logic.

Best regards
Sven

On 06/17/2014 03:55 PM, Daniel Stoch wrote:
> Hi,
>
> I have a link (or ajax link) which executes some system command. This
> system gives me an information if this command is enabled or not, so I
> can mark my link as enabled or disabled (by calling
> setEnabled(command.isEnabled()) or overriding link.isEnabled()
> method).
>
> 1. Page is being rendered, command is enabled so link is rendered as enabled.
> 2. In the meantime system state is changed so command became disabled.
> 3. User clicks link on a page rendered in step 1 where link is
> rendered as enabled but it is disabled now.
>
> In Wicket 1.4 nothing happens in such situation and only warning was logged:
> "component not enabled or visible; ignoring call. Component:
> [MarkupContainer [Component id = link]]"
>
> In Wicket 6 in such situation the exception is raised:
> "ListenerInvocationNotAllowedException: Behavior rejected interface invocation."
>
> How should I handle this correctly to show some information to user,
> that this is link is no longer active (but user should stay on the
> same page)?
> Should I catch ListenerInvocationNotAllowedException inside
> IRequestCycleListener.onException()?
>
> --
> Daniel
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org