You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by "Ben Weidig (Jira)" <ji...@apache.org> on 2023/09/10 12:41:00 UTC
[jira] [Assigned] (TAP5-2763) @RequestParameter improved blank handling
[ https://issues.apache.org/jira/browse/TAP5-2763?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ben Weidig reassigned TAP5-2763:
--------------------------------
Assignee: Ben Weidig
> @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
> Assignee: Ben Weidig
> Priority: Minor
>
> 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)