public void defer(Runnable command) { delegate.defer(command); }
void processSubmission(final String elementName, final String context) { if (disabled) { return; } String value = request.getParameter(elementName); if (value == null) { return; } Runnable sendNotification = new Runnable() { public void run() { resources.triggerEvent(event, new Object[]{context}, null); } }; // When not deferred, don't wait, fire the event now (actually, at the end of the current // heartbeat). This is most likely because the Submit is inside a Loop and some contextual // information will change if we defer. if (defer) { formSupport.defer(sendNotification); } else { heartbeat.defer(sendNotification); } }
void processSubmission(String clientId, String elementName) { if (disabled || !selected(clientId, elementName)) return; // TAP5-1658: copy the context of the current Submit instance so we trigger the event with // the correct context later final Holder<Object[]> currentContextHolder = Holder.create(); if (context != null) { Object[] currentContext = new Object[context.length]; System.arraycopy(context, 0, currentContext, 0, context.length); currentContextHolder.put(currentContext); } Runnable sendNotification = new Runnable() { public void run() { // TAP5-1024: allow for navigation result from the event callback resources.triggerEvent(event, currentContextHolder.get(), eventCallback); } }; // When not deferred, don't wait, fire the event now (actually, at the end of the current // heartbeat). This is most likely because the Submit is inside a Loop and some contextual // information will change if we defer. if (defer) formSupport.defer(sendNotification); else heartbeat.defer(sendNotification); }
private void processSubmission(String clientId) { this.clientId = clientId; String raw = request.getParameter(Form.SUBMITTING_ELEMENT_ID); if (InternalUtils.isNonBlank(raw) && new JSONArray(raw).getString(0).equals(clientId)) { Runnable notification = new Runnable() { public void run() { resources.triggerEvent(event, context, eventCallback); } }; if (defer) formSupport.defer(notification); else heartbeat.defer(notification); } }
@Test public void test_submit_event_fired() { Request request = mockRequest(); final ComponentResources resources = mockComponentResources(); FormSupport formSupport = mockFormSupport(); String elementName = "myname"; train_getParameter(request, Form.SUBMITTING_ELEMENT_ID, null); train_getParameter(request, elementName, "login"); formSupport.defer(isA(Runnable.class)); replay(); Submit submit = new Submit(request); TestBase.set(submit, "resources", resources, "formSupport", formSupport); submit.processSubmission("xyz", elementName); verify(); } }
@Test public void test_imagesubmit_event_fired() { Request request = mockRequest(); final ComponentResources resources = mockComponentResources(); FormSupport formSupport = mockFormSupport(); Asset image = mockAsset(); String elementName = "myname"; train_getParameter(request, Form.SUBMITTING_ELEMENT_ID, null); train_getParameter(request, elementName + ".x", "15"); formSupport.defer(isA(Runnable.class)); replay(); Submit submit = new Submit(request); TestBase.set(submit, "resources", resources, "formSupport", formSupport, "image", image); submit.processSubmission("xyz", elementName); verify(); }