Search in sources :

Example 1 with RequestAttribute

use of com.revolsys.ui.web.annotation.RequestAttribute in project com.revolsys.open by revolsys.

the class WebMethodHandler method requestAttribute.

public static WebParameterHandler requestAttribute(final WebAnnotationMethodHandlerAdapter adapter, final Parameter parameter, final Annotation annotation) {
    final Class<?> parameterClass = parameter.getType();
    final DataType dataType = DataTypes.getDataType(parameterClass);
    final RequestAttribute requestAttribute = (RequestAttribute) annotation;
    final String name = getName(parameter, requestAttribute.value());
    final boolean required = requestAttribute.required();
    final Object defaultValue = parseDefaultValueAttribute(dataType, requestAttribute.defaultValue());
    return // 
    WebParameterHandler.function(// 
    name, (request, response) -> {
        return request.getAttribute(name);
    }, // 
    dataType, // 
    required, // 
    defaultValue);
}
Also used : RequestAttribute(com.revolsys.ui.web.annotation.RequestAttribute) DataType(com.revolsys.datatype.DataType)

Aggregations

DataType (com.revolsys.datatype.DataType)1 RequestAttribute (com.revolsys.ui.web.annotation.RequestAttribute)1