public void setEncodingType(String encodingType) { delegate.setEncodingType(encodingType); }
public void defer(Runnable command) { delegate.defer(command); }
public void addValidation(Field field, String validationName, String message, Object constraint) { delegate.addValidation(field, validationName, message, constraint); }
@SetupRender final void setup() { // Often, these controlName and clientId will end up as the same value. There are many // exceptions, including a form that renders inside a loop, or a form inside a component // that is used multiple times. if (formSupport == null) throw new RuntimeException(String.format("Component %s must be enclosed by a Form component.", resources.getCompleteId())); assignedClientId = allocateClientId(); String controlName = formSupport.allocateControlName(assignedClientId); formSupport.storeAndExecute(this, new Setup(controlName)); formSupport.store(this, PROCESS_SUBMISSION_ACTION); }
boolean beginRender(MarkupWriter writer) { if (formSupport == null) { throw new RuntimeException("The Hidden component must be enclosed by a Form component."); } controlName = formSupport.allocateControlName(resources.getId()); clientId = null; formSupport.store(this, new ProcessSubmission(controlName)); Object toEncode = value == null ? nulls.replaceToClient() : value; String encoded = toEncode == null ? "" : encoder.toClient(toEncode); hiddenInputElement = writer.element("input", "type", "hidden", "name", controlName, "value", encoded); resources.renderInformalParameters(writer); writer.end(); return false; }
/** * Returns the empty block, or null, after the render has finished. It will only be the empty block (which itself * may be null) if the source was null or empty. */ Block cleanupRender() { if (storeValuesInForm) formSupport.store(this, NOTIFY_CONTAINER); return cleanupBlock; }
public <T> void storeCancel(T component, ComponentAction<T> action) { delegate.storeCancel(component, action); } }
public String allocateControlName(String id) { return delegate.allocateControlName(id); }
ComponentAction<RadioGroup> action = new Setup(formSupport.allocateControlName(clientId)); formSupport.storeAndExecute(this, action); formSupport.store(this, PROCESS_SUBMISSION);
void beginRender(MarkupWriter writer) { clientId = null; String name = formSupport.allocateControlName(resources.getId()); // Save the element, to see if an id is later requested. String type = image == null ? "submit" : "image"; element = writer.element("input", "type", type, "name", name); if (disabled) { writer.attributes("disabled", "disabled"); } if (image != null) { writer.attributes("src", image.toClientURL()); } formSupport.store(this, new ProcessSubmission(name, context)); resources.renderInformalParameters(writer); }
public <T> void store(T component, ComponentAction<T> action) { delegate.store(component, action); }
void onBeginRenderFromForm() { formSupport.storeCancel(this, new AddMessage()); }
public void render(MarkupWriter writer) { support.setEncodingType("x-override"); } };
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 beginRender(MarkupWriter writer) { clientId = javascriptSupport.allocateClientId(resources); String name = formSupport.allocateControlName(resources.getId()); // Save the element, to see if an id is later requested. String type = image == null ? "submit" : "image"; writer.element("input", "type", type, "name", name, "data-submit-mode", mode.name().toLowerCase(), "class", cssClass, "id", clientId); if (disabled) { writer.attributes("disabled", "disabled"); } if (image != null) { writer.attributes("src", image.toClientURL()); } formSupport.store(this, new ProcessSubmission(clientId, name)); resources.renderInformalParameters(writer); }
@SetupRender boolean setup() { index = 0; iterator = source == null ? null : source.iterator(); boolean insideForm = formSupport != null; storeValuesInForm = insideForm && formState == LoopFormState.VALUES; storeIncrementsInForm = insideForm && formState == LoopFormState.ITERATION; storeHeartbeatsInForm = insideForm && formState != LoopFormState.NONE; if (storeValuesInForm) formSupport.store(this, PREPARE_FOR_SUBMISSION); // Only render the body if there is something to iterate over boolean hasContent = iterator != null && iterator.hasNext(); if (insideForm && hasContent) { if (storeValuesInForm) formSupport.store(this, RESET_INDEX); if (storeIncrementsInForm) formSupport.store(this, SETUP_FOR_VOLATILE); } cleanupBlock = hasContent ? null : empty; // Jump directly to cleanupRender if there is no content return hasContent; }
public class MyValidator extends AbstractValidator { @Inject private Dao dao; public void render(Field field, String constraintValue, MessageFormatter formatter, MarkupWriter writer, FormSupport formSupport) { // this is the serverside representation of the field which will be rendered to HTML Element fieldElement = writer.getElement(); List<String> values= dao.getSomeList(constraintValue); String valuesAsString = values.toString(); // add an attribute to the DOM, this can be referenced in javascript later fieldElement.attribute("data-values", valuesAsString); formSupport.addValidation(...); } }
/** * Render the upload tags. * * @param writer * Writer to output markup */ protected void beginRender(MarkupWriter writer) { formSupport.setEncodingType(MULTIPART_ENCTYPE); writer.element("input", "type", "file", "name", getControlName(), "id", getClientId(), "class", cssClass); validate.render(writer); resources.renderInformalParameters(writer); decorateInsideField(); // TAPESTRY-2453 if (request.isXHR()) { javaScriptSupport.require("t5/core/injected-upload").with(getClientId()); } }
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); }
void beginRender() { formSupport.store(this, new TriggerEvent(BEGIN_SUBMIT_EVENT)); }