You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Timo Rantalaiho (JIRA)" <ji...@apache.org> on 2007/06/06 07:52:26 UTC

[jira] Commented: (WICKET-606) AbstractTextComponent#setConvertEmptyInputStringToNull(true) does not work with IObjectClassAwareModels (affects TextField, etc.)

    [ https://issues.apache.org/jira/browse/WICKET-606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12501802 ] 

Timo Rantalaiho commented on WICKET-606:
----------------------------------------

After I updated to a fresh 1.3.0 snapshot today (and these changes got applied), one of our tests started failing because a TextField got its input trimmed even though we didn't want it to happen.

What does the trimming is FormComponent.convertValue():

        protected Object convertValue(String[] value) throws ConversionException
        {
                return value != null && value.length > 0 && value[0] != null ? value[0].trim() : null;
        }

So I think that a side effect of these changes has been that now FormComponent.convertValue() gets always called to String-type text components (at least when using a PropertyModel). 

I find it suspicious that the framework would always trim input by default; at least it could be overridable (though you can already override the whole convertValue()). What puzzles me a bit more is how this side effect was caused by these changes.

What do you think?

> AbstractTextComponent#setConvertEmptyInputStringToNull(true) does not work with IObjectClassAwareModels (affects TextField, etc.)
> ---------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-606
>                 URL: https://issues.apache.org/jira/browse/WICKET-606
>             Project: Wicket
>          Issue Type: Bug
>    Affects Versions: trunk
>            Reporter: Alastair Maw
>            Assignee: Alastair Maw
>            Priority: Blocker
>             Fix For: 1.3.0-beta2
>
>
> The unit tests ought to cover this, but apparently don't. A TextField should convert empty strings to nulls if you call setConvertEmptyInputStringToNull(true) on it (which the constructors do by default).
> However, this doesn't currently work:
>  - AbstractTextComponent#getConvertEmptyInputStringToNull() is only called from AbstractTextComponent#convertValue(String[]).
>  - AbstractTextComponent#convertValue(String[]) is called from FormComponent#convert(), but only if the component doesn't have a type assigned to it.
>  - As soon as you use a PropertyModel (which implements IObjectClassAwareModel), this means empty strings are no longer converted to nulls.
> This is obviously a great big blocker and needs fixing ASAP.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.