Ben Weidig created TAP5-2763: -------------------------------- Summary: @RequestParameter improved blank handling Key: TAP5-2763 URL: https://issues.apache.org/jira/browse/TAP5-2763 Project: Tapestry 5 Issue Type: Improvement Components: tapestry-core Affects Versions: 5.8.3 Reporter: Ben Weidig
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. -- This message was sent by Atlassian Jira (v8.20.10#820010)