final Component component = getTarget();
final String id = getRequestParameters().getBehaviorId();
if (id == null)
{
// wicket-2107
throw new PageExpiredException(
"Parameter behaviorId was not provided: unable to locate listener. Component: " +
component.toString());
}
final int idAsInt = Integer.parseInt(id);
final List<IBehavior> behaviors = component.getBehaviorsRawList();
IBehaviorListener behaviorListener = null;
if (behaviors.size() > idAsInt)
{
IBehavior behavior = behaviors.get(idAsInt);
if (behavior instanceof IBehaviorListener)
{
behaviorListener = (IBehaviorListener)behavior;
}
}
if (behaviorListener == null)
{
// wicket-2107
throw new PageExpiredException("No behavior listener found with behaviorId " + id +
"; Component: " + component.toString());
}
// Invoke the interface method
behaviorListener.onRequest();