[
https://issues.apache.org/jira/browse/WICKET-3269?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12975894#action_12975894
]
Igor Vaynberg commented on WICKET-3269:
---------------------------------------
>> it makes sense that empty strings are converted to nulls, this is what 99%
>> of users expect.
>I have to disagree on this generalized statement.
you are free to disagree, but the fact remains that this is the first time it
has come up in many years to my knowledge.
>>what if the TextField holds an Integer? we cant push an empty string into the
>>model then, but we can a >null. nulls are
>>more universal then empty strings.
>This is a straw man argument: This feature request has no intention to change
>anything about handling type conversion
>and/or null conversion of non-String types. It's about removing the special
>handling of the String type.
so why should wicket treat strings differently then other types? if we convert
an empty integer field to a null why shouldnt we a string? didnt you make the
argument that things should work consistently?
>>providing an application-wide setting also will not work as it will break
>>component
>> libs that expect empty >strings to be converted to nulls.
>Do you have an example case where this would be problematic?
i write a component library that has a component that depends on the empty
string converted to null, you throw it into your app where the default is not
to, my component now breaks
conversely, i write a component that assumes the setting is to convert to empty
strings, you drop it into the app where its not, results in an NPE
>>it is not a job of a converter to perform value->null conversions. converters
>>are there for type conversion,
>>not string manipulation.
>Actually they do so already, see AbstractIntegerConverter subclasses as
>examples.
that code is there to protect against an edgecase when a locale can convert a
nonempty string value into null
>>this can be toggled application-wide by using
>>IComponentOnBeforeRenderListener to toggle the setting to false
>This wouldn't allow to explicitly change the setting for a single component.
of course it would, tag the components you want left alone with a piece of
metadata and make the listener check for it
i would actually like to hear the usecase for why you would want empty strings
rather then nulls other then "its a requirement in our application".
if you want more feedback you have more chances if you move this thread to dev@
> Review AbstractTextComponent's handling of empty Strings in 1.5
> ---------------------------------------------------------------
>
> Key: WICKET-3269
> URL: https://issues.apache.org/jira/browse/WICKET-3269
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Affects Versions: 1.5-M3
> Reporter: Sven Meier
> Assignee: Igor Vaynberg
> Attachments: AbstractTextComponent_A.diff,
> AbstractTextComponent_B.diff, WICKET-3269-test.patch, WICKET-3269.patch
>
>
> Context:
> With convertEmptyInputStringToNull set to 'true' (the default),
> AbstractTextComponent converts empty strings to 'null'.
> This works only if the component doesn't know its model type.
> Problem:
> In our application we would like to always keep empty Strings as they are. We
> tried to use a ComponentInstantiationListener to set
> convertEmptyInputStringToNull to 'false', but regretfully
> AbstractTextComponent reverts this setting to 'true' in its constructor.
> Proposals for 1.5 (either A or B):
> A) Change default of convertEmptyInputStringToNull to 'false'.
> - allows applications to keep empty strings as they are,
> - if needed, clients can use a ComponentInstantiationListener to globally set
> convertEmptyInputStringToNull to 'true' for the old default
> B) Remove support for special handling of empty strings.
> - no special handling in #convertValue(String[]) and #resolveType() needed,
> - no more ambiguity whether ConvertEmptyInputStringToNull has any effect
> (model type known or not),
> - if needed, clients can use a custom Converter to convert empty strings to
> 'null'.
> See attached patches, note that no unit tests changes were required.
> Thanks for your consideration.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.