private boolean selected(String clientId, String elementName) { // Case #1: via JavaScript, the client id is passed up. String raw = request.getParameter(Form.SUBMITTING_ELEMENT_ID); if (InternalUtils.isNonBlank(raw) && new JSONArray(raw).getString(0).equals(clientId)) { return true; } // Case #2: No JavaScript, look for normal semantic (non-null value for the element's name). // If configured as an image submit, look for a value for the x position. Ah, the ugliness // of HTML. String name = image == null ? elementName : elementName + ".x"; String value = request.getParameter(name); return value != null; }
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); } }
private boolean isFormCancelled() { // The "cancel" query parameter is reserved for this purpose; if it is present then the form was canceled on the // client side. For image submits, there will be two parameters: "cancel.x" and "cancel.y". if (request.getParameter(InternalConstants.CANCEL_NAME) != null || request.getParameter(InternalConstants.CANCEL_NAME + ".x") != null) { return true; } // When JavaScript is involved, it's more complicated. In fact, this is part of HLS's desire // to have all forms submit via XHR when JavaScript is present, since it would provide // an opportunity to get the submitting element's value into the request properly. String raw = request.getParameter(SUBMITTING_ELEMENT_ID); if (InternalUtils.isNonBlank(raw) && new JSONArray(raw).getString(1).equals(InternalConstants.CANCEL_NAME)) { return true; } return false; }
@Override protected void processSubmission(String controlName) { String parameterValue = request.getParameter(controlName); JSONArray values = new JSONArray(parameterValue); // Use a couple of local variables to cut down on access via bindings Collection<Object> selected = this.selected; selected.clear(); ValueEncoder encoder = this.encoder; // TODO: Validation error if the model does not contain a value. int count = values.length(); for (int i = 0; i < count; i++) { String value = values.getString(i); Object objectValue = encoder.toValue(value); selected.add(objectValue); } putPropertyNameIntoBeanValidationContext("selected"); try { fieldValidationSupport.validate(selected, resources, validate); this.selected = selected; } catch (final ValidationException e) { validationTracker.recordError(this, e.getMessage()); } removePropertyNameFromBeanValidationContext(); }
for (int i = 0; i < count; i++) String value = values.getString(i);
final String eventName = componentEvents.getString(i); JSONObject event = new JSONObject(); event.put(PUBLISH_COMPONENT_EVENTS_URL_PROPERTY, containerResources.createEventLink(eventName).toString());