Search in sources :

Example 1 with Argument

use of com.revolsys.ui.web.config.Argument in project com.revolsys.open by revolsys.

the class IafServlet method processArguments.

/**
 * @param page
 * @param request
 * @throws PageNotFoundException
 */
private void processArguments(final Page page, final HttpServletRequest request) throws ActionException {
    for (final Object element : page.getArguments()) {
        final Argument argument = (Argument) element;
        final String name = argument.getName();
        Object value = null;
        String stringValue = request.getParameter(name);
        if (stringValue == null) {
            stringValue = argument.getDefault();
        }
        if (stringValue != null) {
            final Class argumentType = argument.getType();
            try {
                value = argument.valueOf(stringValue);
            } catch (final NumberFormatException e) {
                throw new PageNotFoundException("Page argument is not a valid number: " + name);
            }
        }
        if (value != null) {
            request.setAttribute(name, value);
        } else if (argument.isRequired()) {
            throw new PageNotFoundException("Missing page argument: " + name);
        }
    }
}
Also used : PageNotFoundException(com.revolsys.ui.web.exception.PageNotFoundException) Argument(com.revolsys.ui.web.config.Argument)

Aggregations

Argument (com.revolsys.ui.web.config.Argument)1 PageNotFoundException (com.revolsys.ui.web.exception.PageNotFoundException)1