use of org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException in project wicket by apache.
the class FormSubmitTest method submitDisabledOuterForm.
/**
*/
@Test
public void submitDisabledOuterForm() {
outerForm.setEnabled(false);
assertEnabledState(false, true, true);
FormTester formTester = tester.newFormTester("outerForm");
try {
formTester.submit("submit");
fail("Executing the listener on disabled component is not allowed.");
} catch (ListenerInvocationNotAllowedException expected) {
;
}
assertOnSubmitCalled(false, false, false);
assertOnErrorCalled(false, false, false);
}
use of org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException in project wicket by apache.
the class FormTesterTest method noParametersCreatedForDisabledComponents.
/**
* @throws Exception
*/
@Test
public void noParametersCreatedForDisabledComponents() throws Exception {
tester.startPage(new MockFormPage() {
private static final long serialVersionUID = -3023635650340910221L;
@Override
protected void onBeforeRender() {
super.onBeforeRender();
// on first rendering there can't be any form parameters.
// on second rendering there must not be any since we disable the form.
// the components all get rendered as disabled, so the browser would not send
// any parameters. thus FormTester must not send any either.
assertTrue(getRequest().getPostParameters().getParameterNames().isEmpty());
}
});
final Component form = tester.getComponentFromLastRenderedPage("form");
form.setEnabled(false);
assertFalse(form.isEnabled());
Component check = tester.getComponentFromLastRenderedPage("form:checkbox");
assertTrue(check.isEnabled());
assertFalse(check.isEnabledInHierarchy());
FormTester formTester = tester.newFormTester("form");
try {
formTester.submit();
fail("Executing the listener on disabled component is not allowed.");
} catch (ListenerInvocationNotAllowedException expected) {
// expected
}
}
use of org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException in project wicket by apache.
the class RequestListenerInterface method invoke.
/**
* Invokes a given interface on a component.
*
* @param rcomponent
* The component
*
* @throws ListenerInvocationNotAllowedException
* when listener invocation attempted on a component that does not allow it
*/
public final void invoke(final IRequestableComponent rcomponent) {
// we are in Wicket core land
final Component component = (Component) rcomponent;
if (!component.canCallListener()) {
// just return so that we have a silent fail and just re-render the
// page
log.info("component not enabled or visible; ignoring call. Component: " + component);
throw new ListenerInvocationNotAllowedException(component, null, "Component rejected interface invocation");
}
internalInvoke(component, component);
}
use of org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException in project wicket by apache.
the class RequestListenerInterface method invoke.
/**
* Invokes a given interface on a component's behavior.
*
* @param rcomponent
* The component
* @param behavior
* @throws ListenerInvocationNotAllowedException
* when listener invocation attempted on a component that does not allow it
*/
public final void invoke(final IRequestableComponent rcomponent, final Behavior behavior) {
// we are in Wicket core land
final Component component = (Component) rcomponent;
if (!behavior.canCallListener(component)) {
log.warn("behavior not enabled; ignore call. Behavior {} at component {}", behavior, component);
throw new ListenerInvocationNotAllowedException(component, behavior, "Behavior rejected interface invocation. ");
}
internalInvoke(component, behavior);
}
Aggregations