[ 
https://issues.apache.org/jira/browse/TAP5-2763?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17768363#comment-17768363
 ] 

ASF subversion and git services commented on TAP5-2763:
-------------------------------------------------------

Commit c55d039af792c7b2052473d3219f3acd71888c1a in tapestry-5's branch 
refs/heads/TAP5-2763 from Ben Weidig
[ https://gitbox.apache.org/repos/asf?p=tapestry-5.git;h=c55d039af ]

TAP5-2763: improve @RequestParameter blank handling

@RequestParamter now also has "boolean treatBlankAsNull() default false" to 
better handl blank values.

A value might be blank, even if it's supposed to be a null coming from the 
client, as any parameter in a request set to null will end up as blank on the 
server side.
This might lead to coercion problems if no sensible coercer from blank to the 
target type exists.
To keep the handling as close to the original, an additional annotation 
parameter made more sense than changing the overall handling.


> @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)

Reply via email to