Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-1567

Poor error reporting in the select freemarker template

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.2
    • 2.0.3
    • Plugin - Tags
    • None

    Description

      Freemarker throws a stack trace when the value for option is null. (This is using a LinkedHashMap as the source for the select list) Just seeing the error, it is hard to figure out what is causing it. Secondly, it seems like the select template should handle this better, like check if the value is null and render an empty select option. (e.g. <option value="">Not a valid selection) This would make it easier to figure out which option is the issue and it wouldn't throw an ugly stacktrace.

      This is the resulting freemarker error:
      --------------------
      Error on line 48, column 13 in template/simple/select.ftl
      stack.findString(parameters.listValue) is undefined.
      It cannot be assigned to itemValue
      The problematic instruction:
      ----------
      ==> assignment: itemValue=stack.findString(parameters.listValue) [on line 48, column 13 in template/simple/select.ftl]
      in user-directive s.iterator [on line 40, column 1 in template/simple/select.ftl]
      in include "/${parameters.templateDir}/simple/select.ftl" [on line 2, column 1 in template/xhtml/select.ftl]
      ----------

      Java backtrace for programmers:
      ----------
      freemarker.core.InvalidReferenceException: Error on line 48, column 13 in template/simple/select.ftl
      stack.findString(parameters.listValue) is undefined.
      It cannot be assigned to itemValue
      at freemarker.core.Assignment.accept(Assignment.java:111)
      at freemarker.core.Environment.visit(Environment.java:196)
      at freemarker.core.IfBlock.accept(IfBlock.java:82)
      ...

      Attachments

        Issue Links

          Activity

            People

              mrdon Donald J. Brown
              tschneider Thomas Schneider
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: