On 02 Apr 2011, at 00:13, Bruno Borges wrote:

> [    ] Please, check this box if you agree with EULA
> [ x ] Please, uncheck this box if you don't want to receive notifications
> 
> 
> In this case, I would set the first checkbox as required, and leave the
> later as optional.
> 
> Vote for (1) +1

Please don't pretend a checkbox is a Radio component.  This is irrelevant to 
this discussion.

> 
> Best regards,
> 
> Bruno Borges
> www.brunoborges.com.br
> +55 21 76727099
> 
> "The glory of great men should always be
> measured by the means they have used to
> acquire it."
> - Francois de La Rochefoucauld
> 
> 
> 
> On Fri, Apr 1, 2011 at 6:46 PM, Maarten Billemont <[email protected]> wrote:
> 
>> 
>> On 01 Apr 2011, at 20:56, Daniel Neugebauer wrote:
>> 
>>> BTW an empty string (that's not null) is a string nevertheless. Following
>> the argument that an unchecked (false) checkbox should be regarded as valid
>> if it is required, an empty string should be accepted as a valid input as
>> well.
>> 
>> I don't see why you would think that.  setRequired(true) means, "You must
>> provide a value for this component's model".  An empty String and a null
>> String mean the same thing (since you cannot input a null String); in both
>> instances, it's the user saying: "I have no value for this".  Hence, it
>> makes perfect sense that the setRequired(true) fails validation on an empty
>> text field.
>> 
>> Contrary to a text field, an unchecked checkbox does not mean: "no value".
>> It means: "Off".  As though I'd write "false" in my text field.
>> 
>> If the web application asks me whether I want to gift-wrap my purchase,
>> leaving the box unchecked does not mean I can't or don't want to make up my
>> mind.  It means I do not want it gift wrapped.  It's me saying: "No."
>> 
>>> I've just tested it with Wicket 1.4 and actually both of the following
>> TextFields validate to a failed state:
>>> 
>>>   TextField tf1 = new TextField("text1", new PropertyModel<String>(this,
>> "test1"));
>>>   tf1.setRequired(true);
>>>   tf1.setConvertEmptyInputStringToNull(false);
>>>   form.add(tf1);
>>> 
>>>   TextField tf2 = new TextField("text2", new PropertyModel<String>(this,
>> "test2"));
>>>   tf2.setRequired(true);
>>>   tf2.setConvertEmptyInputStringToNull(true);
>>>   form.add(tf2);
>>> 
>> 
>> Regardless, setConvertEmptyInputStringToNull is not relevant during
>> checkRequired.  It is only used by the developer to say, if the user doesn't
>> enter any characters, make my model object null instead of an empty string.
>> checkRequired checks Strings.isEmpty(), which is perfectly sensible (ref.
>> the first paragraph of this email).
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>> 
>> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to