public class ApplicationRequest extends Object implements Request
Request implementation, mostly delegating method-calls to one of the internal objects.| Modifier and Type | Class and Description |
|---|---|
static class |
ApplicationRequest.ApplicationPath
Helper class used to simplify include conditions for actions and datasources on a page.
Registered as variable PATH, so conditions can look like |
| Constructor and Description |
|---|
ApplicationRequest() |
ApplicationRequest(Request request,
PermissionProcessor permissionProcessor,
RequestSupport requestSupport) |
| Modifier and Type | Method and Description |
|---|---|
void |
addErrorMessage(FieldProcessor fp,
MessageParam localizable)
Adds an error to the
FieldProcessor using FieldProcessor.addErrorMessage(String). |
void |
addErrorMessage(FieldProcessor fp,
MessageParam localizable,
String fieldBinding)
Adds an error to a
FieldDef using
FieldProcessor.addErrorMessage(org.appng.xml.platform.FieldDef, String). |
void |
addParameter(String key,
String value) |
void |
addParameters(Map<String,String> singleParameters) |
void |
addValidationMetaData(MetaData metaData,
ClassLoader classLoader,
Class<?>... groups)
Based on the JSR-303 annotations of the
MetaData's bindclass, this method adds the Validation to
the FieldDefinitions. |
ApplicationRequest.ApplicationPath |
applicationPath()
Creates a new
ApplicationRequest.ApplicationPath to be used to evaluate include-conditions on a page. |
boolean |
canConvert(Class<?> sourceType,
Class<?> targetType) |
boolean |
canConvert(org.springframework.core.convert.TypeDescriptor sourceType,
org.springframework.core.convert.TypeDescriptor targetType) |
<T> T |
convert(Object source,
Class<T> targetType) |
Object |
convert(Object source,
org.springframework.core.convert.TypeDescriptor sourceType,
org.springframework.core.convert.TypeDescriptor targetType) |
void |
fillBindObject(Object instance,
FieldProcessor fp,
RequestContainer container,
ClassLoader classLoader)
Fills the given
bindobject with the (converted) values provided by a RequestContainer. |
List<String> |
getAcceptedTypes(String uploadName) |
ApplicationConfigProvider |
getApplicationConfig() |
Object |
getBindObject(FieldProcessor fp,
RequestContainer container,
ClassLoader classLoader)
Creates, fills and returns a new bindobject.
|
String |
getEncoding() |
Environment |
getEnvironment()
Returns the
Environment for this Request. |
ExpressionEvaluator |
getExpressionEvaluator()
Returns the
ExpressionEvaluator for this Request. |
FieldConverter |
getFieldConverter()
Returns a
FieldConverter |
Map<String,List<FormUpload>> |
getFormUploads()
Returns all
FormUploads for the request as immutable map. |
List<FormUpload> |
getFormUploads(String name)
Returns an immutable
List of all FormUploads for the parameter with the given name. |
String |
getHost()
Returns the host name for this request
|
javax.servlet.http.HttpServletRequest |
getHttpServletRequest() |
LabelSupport |
getLabelSupport() |
Locale |
getLocale()
|
String |
getMessage(String key,
Object... args)
Retrieves a message from the underlying
MessageSource, using the Locale provided by
Environment.getLocale(). |
org.springframework.context.MessageSource |
getMessageSource()
Returns the currently used
MessageSource |
String |
getParameter(String name)
Returns the value for the parameter with the given name.
Note that for a multi-valued parameter, any of the submitted values is returned. |
List<String> |
getParameterList(String name)
Returns a
List containing all the values for the parameter with the given name. |
Set<String> |
getParameterNames()
Returns an immutable
Set containing the names of all request parameters. |
Map<String,String> |
getParameters()
Returns an immutable
Map containing the name of each request-parameter as a key and a single parameter
value as the map's value.Note that for multi-valued parameters, the returned map contains any of the submitted values. |
Map<String,List<String>> |
getParametersList()
Returns an immutable
Map containing the name of each request-parameter as a key and the list of submitted
values as value. |
ParameterSupport |
getParameterSupportDollar()
Returns the
ParameterSupport for this Request. |
PermissionProcessor |
getPermissionProcessor()
Returns the
PermissionProcessor for this Request. |
String |
getRedirectTarget() |
RequestSupport |
getRequestSupport() |
Subject |
getSubject()
|
List<String> |
getUrlParameters()
Returns a list of URL-Parameters for a JSP-page, which are those path-elements appearing after the name of the
JSP-page itself.
|
ValidationProvider |
getValidationProvider() |
Request |
getWrappedRequest() |
void |
handleException(FieldProcessor fp,
Exception e)
Handles an
Exception. |
boolean |
hasParameter(String name)
Checks whether a parameter with the given name exists.
|
org.springframework.http.HttpHeaders |
headers()
Returns the
HttpHeaders for the underlying HttpServletRequest. |
boolean |
isGet()
Checks whether this
Request originates of a HTTP GET-request. |
boolean |
isMultiPart() |
boolean |
isPost()
Checks whether this
Request originates of a HTTP POST-request. |
boolean |
isRedirect()
Checks whether a redirect-target has been set for this
Request. |
boolean |
isValid() |
void |
setAcceptedTypes(String uploadName,
String... types) |
void |
setApplicationConfig(ApplicationConfigProvider applicationConfigProvider) |
void |
setEncoding(String encoding) |
void |
setLabel(Label label) |
void |
setLabels(Config config) |
void |
setLabels(Config config,
ParameterSupport fieldParameters) |
void |
setLabels(Labels labels) |
void |
setLabelSupport(LabelSupport labelSupport) |
void |
setMaxSize(long maxSize) |
void |
setMaxSize(long maxSize,
boolean strict) |
void |
setPermissionProcessor(PermissionProcessor permissionProcessor) |
<T> void |
setPropertyValue(T source,
T target,
String property)
Copies the property from
source to target. |
<T> void |
setPropertyValues(T source,
T target,
MetaData metaData)
|
void |
setRedirectTarget(String redirectTarget) |
void |
setRequestSupport(RequestSupport requestSupport) |
void |
setTempDir(File tempDir) |
void |
setUrlParameters(List<String> urlParameters) |
void |
setValidationProvider(ValidationProvider validationProvider) |
void |
setWrappedRequest(Request wrappedRequest) |
void |
validateBean(Object bean,
FieldProcessor fp,
Class<?>... groups)
Validates the given bean by adding error-messages to the
FieldDef initions, using
FieldProcessor.addErrorMessage(FieldDef, String). |
void |
validateBean(Object bean,
FieldProcessor fp,
String[] excludeBindings,
Class<?>... groups)
Validates the given bean by adding error-messages to the
FieldDef initions, using
FieldProcessor.addErrorMessage(FieldDef, String). |
void |
validateField(Object bean,
FieldProcessor fp,
String fieldBinding,
Class<?>... groups)
Validates a single
FieldDef by adding error-messages to it, using
FieldProcessor.addErrorMessage(FieldDef, String). |
public static final String I18N_VAR
public ApplicationRequest()
public ApplicationRequest(Request request, PermissionProcessor permissionProcessor, RequestSupport requestSupport)
public PermissionProcessor getPermissionProcessor()
RequestPermissionProcessor for this Request.getPermissionProcessor in interface RequestPermissionProcessorpublic void setPermissionProcessor(PermissionProcessor permissionProcessor)
public LabelSupport getLabelSupport()
public void setLabelSupport(LabelSupport labelSupport)
public Request getWrappedRequest()
public void setWrappedRequest(Request wrappedRequest)
public Environment getEnvironment()
RequestSupportEnvironment for this Request.getEnvironment in interface RequestSupportEnvironmentpublic RequestSupport getRequestSupport()
public void setRequestSupport(RequestSupport requestSupport)
public String getRedirectTarget()
public void setRedirectTarget(String redirectTarget)
public boolean canConvert(Class<?> sourceType, Class<?> targetType)
canConvert in interface org.springframework.core.convert.ConversionServicepublic void handleException(FieldProcessor fp, Exception e) throws BusinessException
RequestSupportException. If the given Exception is a BusinessException, the very same
BusinessException is being re-thrown. Otherwise, the Exception is being wrapped into a new
BusinessException which is then being thrown.Exception is a MessageParam, RequestSupport.addErrorMessage(FieldProcessor, MessageParam)
is being called.handleException in interface RequestSupportfp - a FieldProcessore - an ExceptionBusinessExceptionMessageParam,
RequestSupport.addErrorMessage(FieldProcessor, MessageParam)public void addErrorMessage(FieldProcessor fp, MessageParam localizable)
RequestSupportFieldProcessor using FieldProcessor.addErrorMessage(String).
MessageParam.getMessageKey() is used for the message key, MessageParam.getMessageArgs() for the
message arguments.addErrorMessage in interface RequestSupportfp - a FieldProcessorlocalizable - a MessageParamMessageParampublic void addErrorMessage(FieldProcessor fp, MessageParam localizable, String fieldBinding)
RequestSupportFieldDef using
FieldProcessor.addErrorMessage(org.appng.xml.platform.FieldDef, String).
MessageParam.getMessageKey() is used for the message key, MessageParam.getMessageArgs() for the
message arguments.addErrorMessage in interface RequestSupportfp - a FieldProcessorlocalizable - a MessageParamfieldBinding - the binding of the FieldDef to add the error toMessageParampublic <T> T convert(Object source, Class<T> targetType)
convert in interface org.springframework.core.convert.ConversionServicepublic <T> void setPropertyValues(T source,
T target,
MetaData metaData)
RequestSupportsetPropertyValues in interface RequestSupportsource - the source object to read the fields fromtarget - the target object to write the fields tometaData - the MetaDatapublic <T> void setPropertyValue(T source,
T target,
String property)
RequestSupportsource to target.setPropertyValue in interface RequestSupportsource - the source object to read the property fromtarget - the target object to write the property toproperty - the name of the property to setpublic boolean canConvert(org.springframework.core.convert.TypeDescriptor sourceType,
org.springframework.core.convert.TypeDescriptor targetType)
canConvert in interface org.springframework.core.convert.ConversionServicepublic Object convert(Object source, org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)
convert in interface org.springframework.core.convert.ConversionServicepublic Object getBindObject(FieldProcessor fp, RequestContainer container, ClassLoader classLoader) throws BusinessException
RequestSupportfp.getMetaData().getBindClass(). The MetaData's FieldDefinitions are responsible for
which fields are getting filled.getBindObject in interface RequestSupportfp - the current FieldProcessorcontainer - the RequestContainer used to retrieve the values for filling the bindobjectclassLoader - the ClassLoader used to load the bindclassBusinessException - if the bindclass could not be loaded, instantiated or initialized, or if an error occurred during
filling the bindobjectRequestSupport.fillBindObject(Object, FieldProcessor, RequestContainer, ClassLoader)public void fillBindObject(Object instance, FieldProcessor fp, RequestContainer container, ClassLoader classLoader) throws BusinessException
RequestSupportbindobject with the (converted) values provided by a RequestContainer. The type
of the bindobject must match fp.getMetaData().getBindClass(). The MetaData's
FieldDefinitions are responsible for which fields are getting filled.fillBindObject in interface RequestSupportinstance - the bindobject to fillfp - the current FieldProcessorcontainer - the RequestContainer used to retrieve the values for filling the bindobjectclassLoader - the ClassLoader used to load the bindclassBusinessException - bindobject is not assignable from the type returned by
fp.getMetaData().getBindClass()
fp.getMetaData().getBindClass() can not be instanciated
public String getMessage(String key, Object... args)
RequestSupportMessageSource, using the Locale provided by
Environment.getLocale().getMessage in interface RequestSupportkey - the message keyargs - the message argumentspublic org.springframework.context.MessageSource getMessageSource()
RequestSupportMessageSourcegetMessageSource in interface RequestSupportMessageSourcepublic String getHost()
RequestContainergetHost in interface RequestContainerpublic Map<String,List<String>> getParametersList()
RequestContainerMap containing the name of each request-parameter as a key and the list of submitted
values as value.getParametersList in interface RequestContainerMap containing the request parameters (including multi-valued ones)public Map<String,String> getParameters()
RequestContainerMap containing the name of each request-parameter as a key and a single parameter
value as the map's value.RequestContainer.getParametersList() instead if you want to deal with multi-valued parameters.getParameters in interface RequestContainerMap containing the request parameterspublic String getParameter(String name)
RequestContainerRequestContainer.getParameterList(String) instead if you want to deal with a multi-valued parameter.getParameter in interface RequestContainername - the name of the parameterpublic javax.servlet.http.HttpServletRequest getHttpServletRequest()
public Set<String> getParameterNames()
RequestContainerSet containing the names of all request parameters.getParameterNames in interface RequestContainerpublic String getEncoding()
public boolean hasParameter(String name)
RequestContainerhasParameter in interface RequestContainername - the name of the parametertrue if such a parameter exists, false otherwisepublic void setEncoding(String encoding)
public List<String> getParameterList(String name)
RequestContainerList containing all the values for the parameter with the given name.getParameterList in interface RequestContainername - the name of the parameterList (never null, but may be empty) containing all the values for the given parameterpublic boolean isMultiPart()
public boolean isPost()
RequestRequest originates of a HTTP POST-request.public Map<String,List<FormUpload>> getFormUploads()
RequestContainerFormUploads for the request as immutable map. Returns a Map using the parameters name
as a key and a List of FormUploads as the value.getFormUploads in interface RequestContainerMap containing the FileUploadspublic boolean isGet()
RequestRequest originates of a HTTP GET-request.public boolean isValid()
public void setTempDir(File tempDir)
public List<FormUpload> getFormUploads(String name)
RequestContainerList of all FormUploads for the parameter with the given name.getFormUploads in interface RequestContainername - the name of the parametersFormUploads (never null, but may be empty)public void setMaxSize(long maxSize)
public void setMaxSize(long maxSize,
boolean strict)
public Subject getSubject()
RequestgetSubject in interface RequestSubjectpublic ExpressionEvaluator getExpressionEvaluator()
RequestExpressionEvaluator for this Request.getExpressionEvaluator in interface RequestExpressionEvaluatorpublic ParameterSupport getParameterSupportDollar()
RequestParameterSupport for this Request.getParameterSupportDollar in interface RequestParameterSupportpublic boolean isRedirect()
RequestRequest.isRedirect in interface Requesttrue if a redirect-target has been set for this Request, false otherwisepublic void setLabels(Config config)
public final void setLabels(Config config, ParameterSupport fieldParameters)
public void setLabel(Label label)
public void setLabels(Labels labels)
public FieldConverter getFieldConverter()
RequestSupportFieldConvertergetFieldConverter in interface RequestSupportFieldConverterpublic ApplicationConfigProvider getApplicationConfig()
public void setApplicationConfig(ApplicationConfigProvider applicationConfigProvider)
public ValidationProvider getValidationProvider()
public void setValidationProvider(ValidationProvider validationProvider)
public List<String> getUrlParameters()
Requestcontact and the path is /contact/europe/germany, the
resulting List would be equal to Arrays.asList("europe","germany").getUrlParameters in interface RequestPath.getJspUrlParameters()public void validateBean(Object bean, FieldProcessor fp, Class<?>... groups)
ValidationProviderFieldDef initions, using
FieldProcessor.addErrorMessage(FieldDef, String).validateBean in interface ValidationProviderbean - the bean to validatefp - the FieldProcessor containing the MetaData for the beangroups - the JSR-303 validation groups to useFieldProcessor.addErrorMessage(FieldDef, String)public void validateBean(Object bean, FieldProcessor fp, String[] excludeBindings, Class<?>... groups)
ValidationProviderFieldDef initions, using
FieldProcessor.addErrorMessage(FieldDef, String).validateBean in interface ValidationProviderbean - the bean to validatefp - the FieldProcessor containing the MetaData for the beanexcludeBindings - an array of field-bindings to ignore during validationgroups - the JSR-303 validation groups to useFieldProcessor.addErrorMessage(FieldDef, String)public void validateField(Object bean, FieldProcessor fp, String fieldBinding, Class<?>... groups)
ValidationProviderFieldDef by adding error-messages to it, using
FieldProcessor.addErrorMessage(FieldDef, String).validateField in interface ValidationProviderbean - the bean to validatefp - the FieldProcessor containing the MetaData for the beanfieldBinding - the binding of the FieldDef to validategroups - the JSR-303 validation groups to useFieldProcessor.addErrorMessage(FieldDef, String)public void addValidationMetaData(MetaData metaData, ClassLoader classLoader, Class<?>... groups) throws ClassNotFoundException
ValidationProviderMetaData's bindclass, this method adds the Validation to
the FieldDefinitions.addValidationMetaData in interface ValidationProvidermetaData - the MetaData to add the Validations toclassLoader - the ClassLoader to load the MetaDatas bindClassgroups - the JSR-303 validation groups to useClassNotFoundException - if the bindClass can not be loadedMin,
Max,
Size,
Digits,
NotNull,
Future,
Past,
Type,
Pattern,
FileUploadpublic org.springframework.http.HttpHeaders headers()
RequestHttpHeaders for the underlying HttpServletRequest.public ApplicationRequest.ApplicationPath applicationPath()
ApplicationRequest.ApplicationPath to be used to evaluate include-conditions on a page.ApplicationRequest.ApplicationPathPath.getApplicationUrlParameters()Copyright © 2011–2020 aiticon GmbH. All rights reserved.