public class ApplicationRequest extends Object implements Request
Request
implementation, mostly delegating method-calls to one of the internal objects.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 FieldDef initions. |
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
FormUpload s for the request as immutable map. |
List<FormUpload> |
getFormUploads(String name)
Returns an immutable
List of all FormUpload s 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()
Request
PermissionProcessor
for this Request
.getPermissionProcessor
in interface Request
PermissionProcessor
public void setPermissionProcessor(PermissionProcessor permissionProcessor)
public LabelSupport getLabelSupport()
public void setLabelSupport(LabelSupport labelSupport)
public Request getWrappedRequest()
public void setWrappedRequest(Request wrappedRequest)
public Environment getEnvironment()
RequestSupport
Environment
for this Request
.getEnvironment
in interface RequestSupport
Environment
public 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.ConversionService
public void handleException(FieldProcessor fp, Exception e) throws BusinessException
RequestSupport
Exception
. 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 RequestSupport
fp
- a FieldProcessor
e
- an Exception
BusinessException
MessageParam
,
RequestSupport.addErrorMessage(FieldProcessor, MessageParam)
public void addErrorMessage(FieldProcessor fp, MessageParam localizable)
RequestSupport
FieldProcessor
using FieldProcessor.addErrorMessage(String)
.
MessageParam.getMessageKey()
is used for the message key, MessageParam.getMessageArgs()
for the
message arguments.addErrorMessage
in interface RequestSupport
fp
- a FieldProcessor
localizable
- a MessageParam
MessageParam
public void addErrorMessage(FieldProcessor fp, MessageParam localizable, String fieldBinding)
RequestSupport
FieldDef
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 RequestSupport
fp
- a FieldProcessor
localizable
- a MessageParam
fieldBinding
- the binding of the FieldDef
to add the error toMessageParam
public <T> T convert(Object source, Class<T> targetType)
convert
in interface org.springframework.core.convert.ConversionService
public <T> void setPropertyValues(T source, T target, MetaData metaData)
RequestSupport
setPropertyValues
in interface RequestSupport
source
- the source object to read the fields fromtarget
- the target object to write the fields tometaData
- the MetaData
public <T> void setPropertyValue(T source, T target, String property)
RequestSupport
source
to target
.setPropertyValue
in interface RequestSupport
source
- 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.ConversionService
public Object convert(Object source, org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)
convert
in interface org.springframework.core.convert.ConversionService
public Object getBindObject(FieldProcessor fp, RequestContainer container, ClassLoader classLoader) throws BusinessException
RequestSupport
fp.getMetaData().getBindClass()
. The MetaData
's FieldDef
initions are responsible for
which fields are getting filled.getBindObject
in interface RequestSupport
fp
- the current FieldProcessor
container
- 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
RequestSupport
bindobject
with the (converted) values provided by a RequestContainer
. The type
of the bindobject
must match fp.getMetaData().getBindClass()
. The MetaData
's
FieldDef
initions are responsible for which fields are getting filled.fillBindObject
in interface RequestSupport
instance
- the bindobject to fillfp
- the current FieldProcessor
container
- 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)
RequestSupport
MessageSource
, using the Locale
provided by
Environment.getLocale()
.getMessage
in interface RequestSupport
key
- the message keyargs
- the message argumentspublic org.springframework.context.MessageSource getMessageSource()
RequestSupport
MessageSource
getMessageSource
in interface RequestSupport
MessageSource
public String getHost()
RequestContainer
getHost
in interface RequestContainer
public Map<String,List<String>> getParametersList()
RequestContainer
Map
containing the name of each request-parameter as a key and the list of submitted
values as value.getParametersList
in interface RequestContainer
Map
containing the request parameters (including multi-valued ones)public Map<String,String> getParameters()
RequestContainer
Map
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 RequestContainer
Map
containing the request parameterspublic String getParameter(String name)
RequestContainer
RequestContainer.getParameterList(String)
instead if you want to deal with a multi-valued parameter.getParameter
in interface RequestContainer
name
- the name of the parameterpublic javax.servlet.http.HttpServletRequest getHttpServletRequest()
public Set<String> getParameterNames()
RequestContainer
Set
containing the names of all request parameters.getParameterNames
in interface RequestContainer
public String getEncoding()
public boolean hasParameter(String name)
RequestContainer
hasParameter
in interface RequestContainer
name
- the name of the parametertrue
if such a parameter exists, false
otherwisepublic void setEncoding(String encoding)
public List<String> getParameterList(String name)
RequestContainer
List
containing all the values for the parameter with the given name.getParameterList
in interface RequestContainer
name
- the name of the parameterList
(never null
, but may be empty) containing all the values for the given parameterpublic boolean isMultiPart()
public boolean isPost()
Request
Request
originates of a HTTP POST-request.public Map<String,List<FormUpload>> getFormUploads()
RequestContainer
FormUpload
s for the request as immutable map. Returns a Map
using the parameters name
as a key and a List
of FormUpload
s as the value.getFormUploads
in interface RequestContainer
Map
containing the FileUpload
spublic boolean isGet()
Request
Request
originates of a HTTP GET-request.public boolean isValid()
public void setTempDir(File tempDir)
public List<FormUpload> getFormUploads(String name)
RequestContainer
List
of all FormUpload
s for the parameter with the given name.getFormUploads
in interface RequestContainer
name
- the name of the parametersFormUpload
s (never null
, but may be empty)public void setMaxSize(long maxSize)
public void setMaxSize(long maxSize, boolean strict)
public Subject getSubject()
Request
getSubject
in interface Request
Subject
public ExpressionEvaluator getExpressionEvaluator()
Request
ExpressionEvaluator
for this Request
.getExpressionEvaluator
in interface Request
ExpressionEvaluator
public ParameterSupport getParameterSupportDollar()
Request
ParameterSupport
for this Request
.getParameterSupportDollar
in interface Request
ParameterSupport
public boolean isRedirect()
Request
Request
.isRedirect
in interface Request
true
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()
RequestSupport
FieldConverter
getFieldConverter
in interface RequestSupport
FieldConverter
public ApplicationConfigProvider getApplicationConfig()
public void setApplicationConfig(ApplicationConfigProvider applicationConfigProvider)
public ValidationProvider getValidationProvider()
public void setValidationProvider(ValidationProvider validationProvider)
public List<String> getUrlParameters()
Request
contact
and the path is /contact/europe/germany
, the
resulting List
would be equal to Arrays.asList("europe","germany")
.getUrlParameters
in interface Request
Path.getJspUrlParameters()
public void validateBean(Object bean, FieldProcessor fp, Class<?>... groups)
ValidationProvider
FieldDef
initions, using
FieldProcessor.addErrorMessage(FieldDef, String)
.validateBean
in interface ValidationProvider
bean
- 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)
ValidationProvider
FieldDef
initions, using
FieldProcessor.addErrorMessage(FieldDef, String)
.validateBean
in interface ValidationProvider
bean
- 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)
ValidationProvider
FieldDef
by adding error-messages to it, using
FieldProcessor.addErrorMessage(FieldDef, String)
.validateField
in interface ValidationProvider
bean
- 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
ValidationProvider
MetaData
's bindclass, this method adds the Validation
to
the FieldDef
initions.addValidationMetaData
in interface ValidationProvider
metaData
- the MetaData
to add the Validation
s toclassLoader
- the ClassLoader
to load the MetaData
s bindClassgroups
- the JSR-303 validation groups to useClassNotFoundException
- if the bindClass can not be loadedMin
,
Max
,
Size
,
Digits
,
NotNull
,
Future
,
Past
,
Type
,
Pattern
,
FileUpload
Copyright © 2011–2019 aiticon GmbH. All rights reserved.