Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2763

@RequestParameter improved blank handling

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 5.8.3
    • None
    • tapestry-core
    • None

    Description

      As ValueEncoders are used to convert a parameter value to its actual type, only Boolean and Number-based types result directly in null for a blank value.
      All other types use their TypeCoercer-based ValueEncoder, which not necessarily work.
      However, I believe that if allowBlank = true is set, then a blank parameter should be able to lead to a null value.

      Three possible changes come to mind to support blank --> null:

      • Always treat blank as null before passing it the ValueEncoder
      • Add boolean treatBlankAsNull() default false; to @RequestParameter, or
      • adding String blankValue() String default ""; to @RequestParameter that is used instead of the parameter value if blank

      Personally, I'd prefer the first option.
      The TypeCoercedValueEncoderFactory would handle Boolean/Number just like before, but @RequestParamter wouldn't crash anymore if no valid coercion is possible for an empty String.

      My proof-of-concept works and I might provide a feature branch soon.

      Attachments

        Activity

          People

            ben-ng Ben Weidig
            ben-ng Ben Weidig
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: