src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java

changeset 86
0a658e53177c
parent 83
24a3596b8f98
child 96
b7b685f31e39
     1.1 --- a/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java	Sat May 30 18:12:38 2020 +0200
     1.2 +++ b/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java	Mon Jun 01 14:46:58 2020 +0200
     1.3 @@ -88,6 +88,7 @@
     1.4  
     1.5      /**
     1.6       * Returns the name of the resource bundle associated with this servlet.
     1.7 +     *
     1.8       * @return the resource bundle base name
     1.9       */
    1.10      protected abstract String getResourceBundleName();
    1.11 @@ -266,6 +267,17 @@
    1.12      }
    1.13  
    1.14      /**
    1.15 +     * Sets the view model object.
    1.16 +     * The type must match the expected type in the JSP file.
    1.17 +     *
    1.18 +     * @param req       the servlet request object
    1.19 +     * @param viewModel the view model object
    1.20 +     */
    1.21 +    public void setViewModel(HttpServletRequest req, Object viewModel) {
    1.22 +        req.setAttribute(Constants.REQ_ATTR_VIEWMODEL, viewModel);
    1.23 +    }
    1.24 +
    1.25 +    /**
    1.26       * Obtains a request parameter of the specified type.
    1.27       * The specified type must have a single-argument constructor accepting a string to perform conversion.
    1.28       * The constructor of the specified type may throw an exception on conversion failures.
    1.29 @@ -281,7 +293,7 @@
    1.30              final String[] paramValues = req.getParameterValues(name);
    1.31              int len = paramValues == null ? 0 : paramValues.length;
    1.32              final var array = (T) Array.newInstance(clazz.getComponentType(), len);
    1.33 -            for (int i = 0 ; i < len ; i++) {
    1.34 +            for (int i = 0; i < len; i++) {
    1.35                  try {
    1.36                      final Constructor<?> ctor = clazz.getComponentType().getConstructor(String.class);
    1.37                      Array.set(array, i, ctor.newInstance(paramValues[i]));

mercurial