Package org.appng.api
Interface RequestSupport
-
- All Superinterfaces:
org.springframework.core.convert.ConversionService
- All Known Subinterfaces:
Request
- All Known Implementing Classes:
ApplicationRequest
,RequestSupportImpl
public interface RequestSupport extends org.springframework.core.convert.ConversionService
Provides commonly used methods for supporting request-processing and filling bindobjects.- Author:
- Matthias Müller
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addErrorMessage(FieldProcessor fp, MessageParam messageParam)
Adds an error to theFieldProcessor
usingFieldProcessor.addErrorMessage(String)
.void
addErrorMessage(FieldProcessor fp, MessageParam messageParam, String fieldBinding)
Adds an error to aFieldDef
usingFieldProcessor.addErrorMessage(org.appng.xml.platform.FieldDef, String)
.void
fillBindObject(Object bindobject, FieldProcessor fp, RequestContainer container, ClassLoader classLoader)
Fills the givenbindobject
with the (converted) values provided by aRequestContainer
.Object
getBindObject(FieldProcessor fp, RequestContainer container, ClassLoader classLoader)
Creates, fills and returns a new bindobject.Environment
getEnvironment()
Returns theEnvironment
for thisRequest
.FieldConverter
getFieldConverter()
Returns aFieldConverter
String
getMessage(String key, Object... args)
Retrieves a message from the underlyingMessageSource
, using theLocale
provided byEnvironment.getLocale()
.org.springframework.context.MessageSource
getMessageSource()
Returns the currently usedMessageSource
void
handleException(FieldProcessor fp, Exception e)
Handles anException
.<T> void
setPropertyValue(T source, T target, String property)
Copies the property fromsource
totarget
.<T> void
setPropertyValues(T source, T target, MetaData metaData)
-
-
-
Method Detail
-
getFieldConverter
FieldConverter getFieldConverter()
Returns aFieldConverter
- Returns:
- a
FieldConverter
-
handleException
void handleException(FieldProcessor fp, Exception e) throws BusinessException
Handles anException
. If the given Exception is aBusinessException
, the very sameBusinessException
is being re-thrown. Otherwise, theException
is being wrapped into a newBusinessException
which is then being thrown.
If the givenException
is aMessageParam
,addErrorMessage(FieldProcessor, MessageParam)
is being called.- Parameters:
fp
- aFieldProcessor
e
- anException
- Throws:
BusinessException
- See Also:
MessageParam
,addErrorMessage(FieldProcessor, MessageParam)
-
addErrorMessage
void addErrorMessage(FieldProcessor fp, MessageParam messageParam)
Adds an error to theFieldProcessor
usingFieldProcessor.addErrorMessage(String)
.MessageParam.getMessageKey()
is used for the message key,MessageParam.getMessageArgs()
for the message arguments.- Parameters:
fp
- aFieldProcessor
messageParam
- aMessageParam
- See Also:
MessageParam
-
addErrorMessage
void addErrorMessage(FieldProcessor fp, MessageParam messageParam, String fieldBinding)
Adds an error to aFieldDef
usingFieldProcessor.addErrorMessage(org.appng.xml.platform.FieldDef, String)
.MessageParam.getMessageKey()
is used for the message key,MessageParam.getMessageArgs()
for the message arguments.- Parameters:
fp
- aFieldProcessor
messageParam
- aMessageParam
fieldBinding
- the binding of theFieldDef
to add the error to- See Also:
MessageParam
-
setPropertyValues
<T> void setPropertyValues(T source, T target, MetaData metaData)
- Parameters:
source
- the source object to read the fields fromtarget
- the target object to write the fields tometaData
- theMetaData
- Throws:
IllegalArgumentException
- if the type ofT
is incompatible toMetaData.getBindClass()
or the bindclass can not be found.
-
setPropertyValue
<T> void setPropertyValue(T source, T target, String property)
Copies the property fromsource
totarget
.- Parameters:
source
- the source object to read the property fromtarget
- the target object to write the property toproperty
- the name of the property to set
-
getBindObject
Object getBindObject(FieldProcessor fp, RequestContainer container, ClassLoader classLoader) throws BusinessException
Creates, fills and returns a new bindobject. The type of the returned object is obtained fromfp.getMetaData().getBindClass()
. TheMetaData
'sFieldDef
initions are responsible for which fields are getting filled.- Parameters:
fp
- the currentFieldProcessor
container
- theRequestContainer
used to retrieve the values for filling the bindobjectclassLoader
- theClassLoader
used to load the bindclass- Returns:
- a new bindobject
- Throws:
BusinessException
- if the bindclass could not be loaded, instantiated or initialized, or if an error occurred during filling the bindobject- See Also:
fillBindObject(Object, FieldProcessor, RequestContainer, ClassLoader)
-
fillBindObject
void fillBindObject(Object bindobject, FieldProcessor fp, RequestContainer container, ClassLoader classLoader) throws BusinessException
Fills the givenbindobject
with the (converted) values provided by aRequestContainer
. The type of thebindobject
must matchfp.getMetaData().getBindClass()
. TheMetaData
'sFieldDef
initions are responsible for which fields are getting filled.- Parameters:
bindobject
- the bindobject to fillfp
- the currentFieldProcessor
container
- theRequestContainer
used to retrieve the values for filling the bindobjectclassLoader
- theClassLoader
used to load the bindclass- Throws:
BusinessException
-- if the type of the
bindobject
is not assignable from the type returned byfp.getMetaData().getBindClass()
- if the type returned by
fp.getMetaData().getBindClass()
can not be instanciated
- if the type of the
-
getMessageSource
org.springframework.context.MessageSource getMessageSource()
Returns the currently usedMessageSource
- Returns:
- a
MessageSource
-
getMessage
String getMessage(String key, Object... args)
Retrieves a message from the underlyingMessageSource
, using theLocale
provided byEnvironment.getLocale()
.- Parameters:
key
- the message keyargs
- the message arguments
-
getEnvironment
Environment getEnvironment()
Returns theEnvironment
for thisRequest
.- Returns:
- the
Environment
-
-