Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-5790

VariableInterpolator & #getThrowExceptionOnMissingResource

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 6.18.0, 7.0.0-M4
    • 6.20.0, 7.0.0-M6
    • wicket
    • None

    Description

      This ticket is a 2 in 1 issue:

      #getThrowExceptionOnMissingResource() is given as VariableInterpolator ctor arg.

      When you want to raise a validation error like:

                  ValidationError error = new ValidationError();
                  error.addKey("MyComponent.ConversionError");
                  error.setVariable("myvar", myvalue);
      
                  this.error(error);
      

      A call is made to FormComponent.MessageSource.substitute which returns new VariableInterpolator(...).toString()

      The second arg to VariableInterpolator is meant for "exceptionOnNullVarValue" but what is supplied in #substitute() is Application.get().getResourceSettings().getThrowExceptionOnMissingResource().

      That's where it looks strange because #getThrowExceptionOnMissingResource() represents a flag about missing resources (like MyComponent.properties) and has nothing related to null values in my understanding.

      ${var} is not replaced in case of null value (and null is allowed)

      In the previous example, if #getThrowExceptionOnMissingResource() return false (meaning exceptionOnNullVarValue is false) and myvalue is null, the validation error message gives something of the form "value of myvar: ${myvar}" instead of "value of myvar: null".

      Attachments

        1. WICKET-5790.zip
          28 kB
          Sebastien Briquet

        Activity

          People

            bitstorm Andrea Del Bene
            sebfz1 Sebastien Briquet
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: