Uploaded image for project: 'Magnolia Standard Templating Kit (closed)'
  1. Magnolia Standard Templating Kit (closed)
  2. MGNLSTK-539

STKPager: Error on manipulating parameters

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Major
    • None
    • 1.1.2
    • paragraphs
    • None
    • Yes

    Description

      By manipulating the STKPager paging-parameter "currentPage" a freemarker exception is thrown.

      The problem occurs by following values:

      • 0
      • empty
      • text
      • big integer
      • very big number (long)

      The function getCurrentPage() should handle the wrong parameters.

          public int getCurrentPage() {
              int currentPage = 1;
              String paramCurrent = MgnlContext.getParameter("currentPage");
              if (StringUtils.isNotBlank(paramCurrent) && StringUtils.isNumeric(paramCurrent)) {
                  try {
                      currentPage = Integer.parseInt(paramCurrent);
                      if (currentPage > getNumPages() || currentPage < 1) {
                          currentPage = 1;
                      }
                  } catch (NumberFormatException e) {
                      log.warn("Wrong currentPage parameter with value [{}] is given. Set currentPage to 1.", paramCurrent);
                  }
              }
              return currentPage;
          }
      

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              pbaerfuss Philipp Bärfuss
              vuce Oliver Emke
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: