Class AbstractValidationBoxHandler<T extends AbstractFormBean>
- java.lang.Object
-
- net.anotheria.anosite.handler.AbstractBoxHandler
-
- net.anotheria.anosite.handler.validation.AbstractValidationBoxHandler<T>
-
- All Implemented Interfaces:
BoxHandler
public abstract class AbstractValidationBoxHandler<T extends AbstractFormBean> extends AbstractBoxHandler
Abstract box handler for handling requests with validation functional.- Author:
- Alexandr Bolbat
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTR_VALIDATION_RESPONSE_STRINGAttribute name for storing validation response string in request.static StringATTR_VALIDATION_SETTINGS_STRINGAttribute name for storing validation settings string in request.static StringJSON_RESPONSE_CODEPAGEJSON response encoding.static StringJSON_RESPONSE_CONTENT_TYPEJSON response content type.static StringREQ_PARAM_VALIDATION_ONLYRequest parameter name for validation request only.
-
Constructor Summary
Constructors Constructor Description AbstractValidationBoxHandler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected TcreateFormBean()Create instance of form bean.protected BoxHandlerResponseexecuteProcess(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, Box box, BoxBean bean)Real process method for overriding in sub classes.protected BoxHandlerResponseexecuteSubmit(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, Box box)Real submit method for overriding in sub classes.protected TgetFormBean(jakarta.servlet.http.HttpServletRequest req)Get form bean.protected abstract Class<T>getFormBeanClass()Form bean implementation class.protected abstract StringgetFormId()Form id for this handler.protected ValidationSettingsgetFormValidationSettings(jakarta.servlet.http.HttpServletRequest req)Use this method if we want put some validation settings to page.protected voidprepareFormValidationSettings(ValidationSettings vSettings)Prepare instant validation settings for current handler form.BoxHandlerResponseprocess(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, Box box, BoxBean bean)Returns ResponseContinue.INSTANCE.protected voidpublishFormBean(T formBean, jakarta.servlet.http.HttpServletRequest req)Publish form bean to request attributes.BoxHandlerResponsesubmit(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, Box box)Returns ResponseContinue.INSTANCE.protected ValidationResponsevalidate(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, Box box)Validate submit request.protected BoxHandlerResponsewriteJSONResponse(jakarta.servlet.http.HttpServletResponse res, String json)Writes JSON response and flush the stream.-
Methods inherited from class net.anotheria.anosite.handler.AbstractBoxHandler
getLog, getResourceDataService, getTextResource, sendAttributeToPage
-
-
-
-
Field Detail
-
JSON_RESPONSE_CODEPAGE
public static final String JSON_RESPONSE_CODEPAGE
JSON response encoding.- See Also:
- Constant Field Values
-
JSON_RESPONSE_CONTENT_TYPE
public static final String JSON_RESPONSE_CONTENT_TYPE
JSON response content type.- See Also:
- Constant Field Values
-
REQ_PARAM_VALIDATION_ONLY
public static final String REQ_PARAM_VALIDATION_ONLY
Request parameter name for validation request only.- See Also:
- Constant Field Values
-
ATTR_VALIDATION_RESPONSE_STRING
public static final String ATTR_VALIDATION_RESPONSE_STRING
Attribute name for storing validation response string in request.- See Also:
- Constant Field Values
-
ATTR_VALIDATION_SETTINGS_STRING
public static final String ATTR_VALIDATION_SETTINGS_STRING
Attribute name for storing validation settings string in request.- See Also:
- Constant Field Values
-
-
Method Detail
-
process
public final BoxHandlerResponse process(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, Box box, BoxBean bean) throws BoxProcessException
Description copied from class:AbstractBoxHandlerReturns ResponseContinue.INSTANCE.- Specified by:
processin interfaceBoxHandler- Overrides:
processin classAbstractBoxHandler- Parameters:
req- the http servlet requestres- the http servlet responsebox- the box this handler has been associated with (and which was currently processed).bean- the already created bean.- Returns:
- response
- Throws:
BoxProcessException
-
submit
public final BoxHandlerResponse submit(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, Box box) throws BoxSubmitException
Description copied from class:AbstractBoxHandlerReturns ResponseContinue.INSTANCE.- Specified by:
submitin interfaceBoxHandler- Overrides:
submitin classAbstractBoxHandler- Parameters:
req- requestres- responsebox- box itself- Returns:
- response
- Throws:
BoxSubmitException
-
executeProcess
protected BoxHandlerResponse executeProcess(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, Box box, BoxBean bean) throws BoxProcessException
Real process method for overriding in sub classes.- Parameters:
req- requestres- responsebox- boxbean- box bean- Returns:
BoxHandlerResponse- Throws:
BoxProcessException- TODO dummy comment for javadoc.
-
executeSubmit
protected BoxHandlerResponse executeSubmit(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, Box box) throws BoxSubmitException
Real submit method for overriding in sub classes.- Parameters:
req- requestres- responsebox- box- Returns:
BoxHandlerResponse- Throws:
BoxSubmitException- TODO dummy comment for javadoc.
-
prepareFormValidationSettings
protected void prepareFormValidationSettings(ValidationSettings vSettings)
Prepare instant validation settings for current handler form.- Parameters:
vSettings- - request instant validation settings, this settings contains settings for every form in request
-
getFormValidationSettings
protected final ValidationSettings getFormValidationSettings(jakarta.servlet.http.HttpServletRequest req)
Use this method if we want put some validation settings to page.- Parameters:
req- TODO dummy comment for javadoc.- Returns:
ValidationSettings
-
getFormBean
protected final T getFormBean(jakarta.servlet.http.HttpServletRequest req)
Get form bean. On first call to this method form bean will be created and prepared from request.- Parameters:
req- request- Returns:
- T TODO dummy comment for javadoc.
-
publishFormBean
protected final void publishFormBean(T formBean, jakarta.servlet.http.HttpServletRequest req)
Publish form bean to request attributes.- Parameters:
formBean- form beanreq- request
-
createFormBean
protected final T createFormBean()
Create instance of form bean.- Returns:
- T TODO dummy comment for javadoc.
-
getFormBeanClass
protected abstract Class<T> getFormBeanClass()
Form bean implementation class.- Returns:
Classof T
-
validate
protected ValidationResponse validate(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, Box box) throws BoxHandleException
Validate submit request.- Parameters:
req- TODO dummy comment for javadoc.res- TODO dummy comment for javadoc.box- TODO dummy comment for javadoc.- Returns:
ValidationResponse- Throws:
BoxHandleException- TODO dummy comment for javadoc.
-
writeJSONResponse
protected final BoxHandlerResponse writeJSONResponse(jakarta.servlet.http.HttpServletResponse res, String json) throws BoxSubmitException
Writes JSON response and flush the stream.- Parameters:
res- HttpServletResponsejson- response- Returns:
BoxHandlerResponseTODO dummy comment for javadoc.- Throws:
BoxSubmitException- TODO dummy comment for javadoc.
-
-