Version 4.10.0

Interface ConvertParamError

public interface ConvertParamError

Instructs WEB4J how to respond to any errors found during parsing of raw user input into 'base' types such as Integer, Date, and so on.

See BuildImpl for important information on how this item is configured. BuildImpl.forConvertParamError() returns the configured implementation of this interface.

On behalf of the application, RequestParser and related classes will parse user input into various target types such as Integer, Date and so on, using the configured implementation of ConvertParam. This centralizes such repetitive parsing into the framework, and allows the application programmer to mostly ignore the possibility of such errors - the try..catch block has already been written.

WEB4J performs such parsing as a soft validation. For example, if user input should be an Integer in the range 0..150, then WEB4J will attempt to parse the raw user input (a String) first into an Integer. If that parse succeeds, then WEB4J will pass the Integer on to an Action, which will then perform further "business validation" using a business domain Model Object - that is, it will check that its value is in the range 0..150. So, an Action and its Model Object can almost always assume that an object of the correct 'base' type already exists, without worrying about low level parsing problems.

However, if user input cannot be parsed by WEB4J into the desired class, then an error message must be displayed to the user. Implementations of this interface allow an application programmer to specify the content of that response message.

Please see the example application for an example implementation.

Method Summary
 ModelCtorException get(Class<?> aSupportedTargetClass, String aUserInputValue, RequestParameter aRequestParameter)
          Return a ModelCtorException for a given parsing error, suitable for presentation to the end user.

Method Detail


ModelCtorException get(Class<?> aSupportedTargetClass,
                       String aUserInputValue,
                       RequestParameter aRequestParameter)
Return a ModelCtorException for a given parsing error, suitable for presentation to the end user.

aSupportedTargetClass - identifies the class into which the user input cannot be successfully parsed
aUserInputValue - value input by the user
aRequestParameter - the request parameter

Version 4.10.0

Copyright Hirondelle Systems. Published October 19, 2013 - User Guide - All Docs.