@SuppressWarnings({"unchecked"}) @Override protected void processSubmission(String controlName) { String submittedValue = request.getParameter(controlName); tracker.recordInput(this, submittedValue); Object selectedValue = toValue(submittedValue); putPropertyNameIntoBeanValidationContext("value"); try { fieldValidationSupport.validate(selectedValue, resources, validate); value = selectedValue; } catch (ValidationException ex) { tracker.recordError(this, ex.getMessage()); } removePropertyNameFromBeanValidationContext(); }
/** * Allows the validation decorator to write markup after the field has written all of its markup. * In addition, may invoke the <code>core/fields:showValidationError</code> function to present * the field's error (if it has one) to the user. */ @AfterRender final void afterDecorator() { decorator.afterField(this); String error = validationTracker.getError(this); if (error != null) { javaScriptSupport .require("t5/core/fields") .invoke("showValidationError") .with(assignedClientId, error); } }
/** Renders the options, including the blank option. */ @BeforeRenderTemplate void options(MarkupWriter writer) { selectedClientValue = tracker.getInput(this); // Use the value passed up in the form submission, if available. // Failing that, see if there is a current value (via the value parameter), and // convert that to a client value for later comparison. if (selectedClientValue == null) selectedClientValue = value == null ? null : encoder.toClient(value); if (showBlankOption()) { writer.element("option", "value", ""); writer.write(blankLabel); writer.end(); } SelectModelVisitor renderer = new Renderer(writer); model.visit(renderer); }