use of org.apache.tapestry5.annotations.RequestParameter in project tapestry-5 by apache.
the class DefaultOpenApiTypeDescriber method describe.
@Override
public void describe(JSONObject description, Parameter parameter) {
describeType(description, parameter.getType());
// According to the OpenAPI 3 documentation, path parameters are always required.
final RequestParameter requestParameter = parameter.getAnnotation(RequestParameter.class);
if (requestParameter == null || requestParameter != null && !requestParameter.allowBlank()) {
description.put("required", true);
}
}
use of org.apache.tapestry5.annotations.RequestParameter in project tapestry-5 by apache.
the class Select method onChange.
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();
}
use of org.apache.tapestry5.annotations.RequestParameter in project tapestry-5 by apache.
the class Autocomplete method onAutocomplete.
Object onAutocomplete(final EventContext context, @RequestParameter("t:input") final String input) {
final Holder<List> matchesHolder = Holder.create();
// Default it to an empty list.
matchesHolder.put(Collections.emptyList());
ComponentEventCallback callback = new ComponentEventCallback() {
public boolean handleResult(Object result) {
List matches = coercer.coerce(result, List.class);
matchesHolder.put(matches);
return true;
}
};
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 coercer.coerce(input, desiredType);
}
return context.get(desiredType, index - 1);
}
};
resources.triggerContextEvent(EventConstants.PROVIDE_COMPLETIONS, newContext, callback);
JSONObject reply = new JSONObject();
reply.put("matches", JSONArray.from(matchesHolder.get()));
// A JSONObject response is always preferred, as that triggers the whole partial page render pipeline.
return reply;
}
use of org.apache.tapestry5.annotations.RequestParameter in project tapestry-5 by apache.
the class DateField method onFormat.
/**
* 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;
}
use of org.apache.tapestry5.annotations.RequestParameter in project tapestry-5 by apache.
the class DateField method onParse.
/**
* 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;
}
Aggregations