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

Customize ValidationError creation by FormComponent

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 6.2.0
    • 6.3.0
    • wicket
    • None

    Description

      When the validation triggered in FormComponent.convertInput() fails, a ValidationError is reported. This ValidationError provides variable substitution for the error message. If you write your own implementation of IConverter and have control over the creation of a ConversionException, you can easily add custom variables to it, which then can be used for substitution. But in case you use one of the implementations provided by wicket, you can't add variables to the ConversionException.

      So I propose to add the possibility to modify the ValidationError object, so a FormComponent can append its own variables to it, or even overwrite values, add new message keys, ..

      I'll attach a patch - just need to figure out how I made a little refactoring and introduced a new method FormComponent.newValidationError(). It encapsulates the creation of the ValidationError and can be overwritten. It also reduces some duplicate lines of code.

      Attachments

        1. FormComponent.newValidationError.patch
          3 kB
          Benedikt Schlegel

        Activity

          People

            mgrigorov Martin Tzvetanov Grigorov
            codecab Benedikt Schlegel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: