Discussion:
How to handle ListenerInvocationNotAllowedException on invisible field
Vishal Popat
2018-11-19 07:52:10 UTC
Permalink
Hi,

I am using Wicket 7...

Recently I have been getting lots of the following exception
WARN RequestCycleExtra:347 - Handling the following exception: org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException: Behavior rejected interface invocation. Component: [TextField [Component id = name]] Behavior: bidding.web.pages.search.RefineSearchFields$***@1471c2d Listener: [RequestListenerInterface name=IBehaviorListener, method=public abstract void org.apache.wicket.behavior.IBehaviorListener.onRequest()]
at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:237)
at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:248)
at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:234)
...

I have the following panel being called from SearchResults web page:
RefineSearchFields refineFields = new RefineSearchFields("refineSearch", getPageParameters());
refineFields.setVisible(doSearch());
add(refineFields);

Within the RefineSearchFields Panel, I have:
final TextField<String> nameField = new TextField<String>("name", new PropertyModel<String>(this, "name"));
OnChangeAjaxBehavior nameFieldBehavior = new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
//do stuff
}
};
nameField.add(nameFieldBehavior);
form.add(nameField);

I have found out why I get this exception... this is due to doSearch() returning false so the RefineSearchFields panel is not visible.
However the behaviour is still added to the field that is invisible.
What I would like, is to not execute/setup RefineSearchFields if its not visible.
What is the Wicket way to do this?

Many thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Martin Grigorov
2018-11-19 08:39:56 UTC
Permalink
Hi,

If a component is invisible then it won't render itself. It might render
just its HTML element if you use
refineFields.setOutputMarkupPlaceholderTag(true), but none of its children
would be rendered, and their Ajax listeners won't bind at all.
So I think the reason is something else.

Often this kind of problem occurs when you override Component#isVisible().
In the first request it returns 'true' and the components and its children
are renderer. But later when the (ajax) request is executed it evaluates to
'false' and thus the exception.
Post by Vishal Popat
Hi,
I am using Wicket 7...
Recently I have been getting lots of the following exception
Behavior rejected interface invocation. Component: [TextField [Component id
Listener: [RequestListenerInterface name=IBehaviorListener, method=public
abstract void org.apache.wicket.behavior.IBehaviorListener.onRequest()]
at
org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:237)
at
org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:248)
at
org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:234)
...
RefineSearchFields refineFields = new RefineSearchFields("refineSearch",
getPageParameters());
refineFields.setVisible(doSearch());
add(refineFields);
final TextField<String> nameField = new TextField<String>("name", new
PropertyModel<String>(this, "name"));
OnChangeAjaxBehavior nameFieldBehavior = new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
//do stuff
}
};
nameField.add(nameFieldBehavior);
form.add(nameField);
I have found out why I get this exception... this is due to doSearch()
returning false so the RefineSearchFields panel is not visible.
However the behaviour is still added to the field that is invisible.
What I would like, is to not execute/setup RefineSearchFields if its not visible.
What is the Wicket way to do this?
Many thanks
---------------------------------------------------------------------
Loading...