public void advise(final MethodInvocation invocation) { heartbeat.defer(new Runnable() { public void run() { invocation.proceed(); } }); } };
private void endHeartbeat() { heartbeat.end(); } }
private void beginHeartbeat() { heartbeat.begin(); }
private void endHeartbeat() { heartbeat.end(); index++; }
private void startHeartbeat() { heartbeat.begin(); }
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); } }
/** * Called at the end of the form render (or at the end of the form submission) to clean up the {@link Environment} * stack. */ void cleanupEnvironment() { heartbeat.end(); environment.pop(PropertyEditContext.class); }
public void setupBeforePartialZoneRender(MarkupWriter writer) { if (formComponentId == null) return; hiddenFieldPositioner = new HiddenFieldPositioner(writer, rules); actionSink = new ComponentActionSink(logger, clientDataEncoder); formSupport = createInternalFormSupport(formClientId, formComponentId, actionSink); environment.push(FormSupport.class, formSupport); environment.push(ValidationTracker.class, new ValidationTrackerImpl()); heartbeat.begin(); }
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); }
@Test public void trigger_immediate() { FormSupport support = mockFormSupport(); ComponentResources resources = mockComponentResources(); Heartbeat heartbeat = new HeartbeatImpl(); Request request = mockRequest(); String elementName = "myname"; train_getParameter(request, Form.SUBMITTING_ELEMENT_ID, null); train_getParameter(request, elementName, "login"); replay(); heartbeat.begin(); Submit submit = new Submit(request); TestBase.set(submit, "resources", resources, "formSupport", support, "heartbeat", heartbeat, "defer", false); submit.processSubmission("xyz", elementName); verify(); expect(resources.triggerEvent(EventConstants.SELECTED, null, null)).andReturn(false); replay(); heartbeat.end(); verify(); }
void afterRender(MarkupWriter writer) { heartbeat.end(); if (insideForm) { environment.pop(FormSupport.class); if (actionSink.isEmpty()) { hiddenFieldPositioner.discard(); } else { hiddenFieldPositioner.getElement().attributes("type", "hidden", "name", Form.FORM_DATA, "value", actionSink.getClientData()); } } writer.end(); // div }
heartbeat.begin();
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); } }
void afterRender(MarkupWriter writer) { environment.peek(Heartbeat.class).end(); formSupport.executeDeferred(); String encodingType = formSupport.getEncodingType(); if (encodingType != null) { form.forceAttributes("enctype", encodingType); } writer.end(); // form div.element("input", "type", "hidden", "name", FORM_DATA, "value", actionSink.getClientData()); div.pop(); if (autofocus) { environment.pop(ValidationDecorator.class); } }
heartbeat.begin();