void onFrob(@RequestParameter(PARAMETER_NAME) int value) { this.value = value; }
@OnEvent("scroll") Object scroll(EventContext context, @RequestParameter("pageNumber") int index) { this.pageNumber = index; this.eventContext = context; return nextPageBlock; }
void onFrobNullAllowed(@RequestParameter(value = PARAMETER_NAME, allowBlank = true) int value) { this.value = value; }
void onAction(@RequestParameter("decorated") boolean decorated) { this.decorated = decorated; } }
void onActivate(@RequestParameter(value="decorated", allowBlank=true) boolean decorated) { this.decorated = decorated; } }
void onMyAction(@RequestParameter(TEST_PARAM_NAME) String value) { result = value; // Expecting: value equals TEST_PARAM_VALUE }
void onSuccessFromSimpleform(@RequestParameter(TEST_PARAM_NAME) String value) { result = value; // Expecting: value equals TEST_PARAM_VALUE }
void onFrobFrob(@RequestParameter(PARAMETER_NAME) Integer[] values) { this.values = Arrays.asList(values); }
void onEmptyStringAllowed(@RequestParameter(value = PARAMETER_NAME, allowBlank = true) Integer value) { if (value == null) { this.value = -1; } else { this.value = value.intValue(); } } }
/** * Ajax event handler, used when initiating the popup. The client sends the input value form the field to the server * to parse it according to the server-side format. The response contains a "result" key of the formatted date in a * format acceptable to the JavaScript Date() constructor. Alternately, an "error" key indicates the the input was * not formatted correct. */ JSONObject onParse(@RequestParameter(INPUT_PARAMETER) String input) { JSONObject response = new JSONObject(); try { Date date = format.parse(input); response.put(RESULT, new SimpleDateFormat("yyyy-MM-dd").format(date)); } catch (ParseException ex) { response.put(ERROR, ex.getMessage()); } return response; }
/** * Ajax event handler, used after the client-side popup completes. The client sends the date, formatted as * milliseconds since the epoch, to the server, which reformats it according to the server side format and returns * the result. * @throws ParseException */ JSONObject onFormat(@RequestParameter(INPUT_PARAMETER) String input) throws ParseException { JSONObject response = new JSONObject(); try { Date date = new SimpleDateFormat("yyyy-MM-dd").parse(input); response.put(RESULT, format.format(date)); } catch (NumberFormatException ex) { response.put(ERROR, ex.getMessage()); } return response; }
Object onTreeAction(@RequestParameter("t:nodeid") String nodeId, @RequestParameter("t:action") String action) { if (action.equalsIgnoreCase("expand")) { return doExpandChildren(nodeId); } if (action.equalsIgnoreCase("markExpanded")) { return doMarkExpanded(nodeId); } if (action.equalsIgnoreCase("markCollapsed")) { return doMarkCollapsed(nodeId); } if (action.equalsIgnoreCase("select")) { return doUpdateSelected(nodeId, true); } if (action.equalsIgnoreCase("deselect")) { return doUpdateSelected(nodeId, false); } throw new IllegalArgumentException(String.format("Unexpected action: '%s' for Tree component.", action)); }
Object onTriggerRemoveRow(@RequestParameter("t:rowvalue") String encodedValue) { syncValue(encodedValue); resources.triggerEvent(EventConstants.REMOVE_ROW, new Object[] {value}, null); return new JSONObject(); }
Object onDismiss(@RequestParameter(value = "id", allowBlank = true) Long alertId) { // If the alert was created inside an Ajax request and AlertStorage did not previously // exist, it can be null when the dismiss event comes up from the client. if (storage != null) { if (alertId != null) { storage.dismiss(alertId); } else { storage.dismissAll(); } } return new JSONObject(); }
Object onDismiss(@RequestParameter(value = "id", allowBlank = true) Long alertId) { // If the alert was created inside an Ajax request and AlertStorage did not previously // exist, it can be null when the dismiss event comes up from the client. if (storage != null) { if (alertId != null) { storage.dismiss(alertId); } else { storage.dismissAll(); } } // See TAP5-1941 if (!request.isXHR()) { return true; } return new JSONObject(); }
Object onChange(final EventContext context, @RequestParameter(value = "t:selectvalue", allowBlank = true) final String selectValue) throws ValidationException { final Object newValue = toValue(selectValue); CaptureResultCallback<Object> callback = new CaptureResultCallback<Object>(); EventContext newContext = new AbstractEventContext() { @Override public int getCount() { return context.getCount() + 1; } @Override public <T> T get(Class<T> desiredType, int index) { if (index == 0) { return typeCoercer.coerce(newValue, desiredType); } return context.get(desiredType, index-1); } }; this.resources.triggerContextEvent(EventConstants.VALUE_CHANGED, newContext, callback); this.value = newValue; return callback.getResult(); }
@Log Object onActionFromSelect(String name, @RequestParameter(QueryParameterConstants.ZONE_ID) String zoneId) { if (!zoneId.equals("output")) throw new AssertionError("Expected zoneId 'output' to be passed up in request."); this.name = name; if (name.equals("Registration")) { return registrationForm; } if (name.equals("Vote")) { return voteForm; } if (name.equals("CSS Injection")) { ajaxResponseRenderer.addCallback(new JavaScriptCallback() { public void run(JavaScriptSupport javascriptSupport) { javascriptSupport.importStylesheet(viaAjaxCSS); } }); return ajaxCSS; } return output.getBody(); }
Object onAutocomplete(final EventContext context, @RequestParameter("t:input") final String input)