On Tue, Jun 17, 2014 at 5:26 PM, Daniel Stoch <daniel.st...@gmail.com> wrote:
> On Tue, Jun 17, 2014 at 4:00 PM, Martin Grigorov <mgrigo...@apache.org> > wrote: > > Hi, > > > > > > On Tue, Jun 17, 2014 at 4:55 PM, Daniel Stoch <daniel.st...@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-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >