You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Thorsten Schöning <ts...@am-soft.de> on 2015/04/01 20:24:58 UTC

Improve Support for placeholder label option for DropDownChoice?

Hi all,

I got the following error during validation of one of my forms today:

> The first child option element of a select element with a required
> attribute, and without a multiple attribute, and without a size
> attribute whose value is greater than 1, must have either an empty
> value attribute, or must have no text content. Consider either
> adding a placeholder option label, or adding a size attribute with a
> value equal to the number of option elements.

The message is about the following spec:

http://dev.w3.org/html5/spec-preview/the-select-element.html#placeholder-label-option

The reason for the error seems simple: I use a DropDownChoice with a
default selected value and null disallowed, so I always need a value.
In that case AbstractSingleSelectChoice.getDefaultChoice doesn't
provide any content, because there's already one value selected and
this is not null. That results in the select gets only rendered with
the choices provided, missing a default option with value "" and so
violating the HTML5 spec... The default option doesn't necessarily
needs to be selected, it just needs to exist if the select is
required.

To resolve this issue I extended DropDownChoice and implemented my own
getDefaultChoice, which simply always returns an option with value ""
if the base implementation returns an empty string.

Is this worth creating an issue in JIRA, either as bug or enhancement?

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Improve Support for placeholder label option for DropDownChoice?

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Sven Meier,
am Donnerstag, 2. April 2015 um 12:40 schrieben Sie:

> What do you mean by 'is not valid'? Whether null is accepted as input
> will be decided by #isRequired().

setRequired is called with true as well, but specifying null as valid
input to the component is wrong in my case and may have additional
side effects in future or whatever.

> You can change these texts, see #getNullValidDisplayValue() and
> #getNullValidKey() or just change the text for "<id>.nullValid" in your
> properties.

I don't see the benefit of giving the key nullValid a wording like
"null is invalid" instead. Additionally I would even have to remember
this behavior for all DropDownChoices in a use case like this one with
default value, only one choice needed and null being invalid.

From my point of view this is better fixed in the component, at least
for HTML5.

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Improve Support for placeholder label option for DropDownChoice?

Posted by Sven Meier <sv...@meiers.net>.
Hi Thorsten,

 > Because null is not valid in my case

What do you mean by 'is not valid'? Whether null is accepted as input 
will be decided by #isRequired().
'Null valid' will give you an additional option as the spec seems to 
demands it.

 > the displayed texts for the placeholder label option are different 
for both null valid vs. invalid cases.

You can change these texts, see #getNullValidDisplayValue() and 
#getNullValidKey() or just change the text for "<id>.nullValid" in your 
properties.

Have fun
Sven

Am 02.04.2015 um 10:16 schrieb Thorsten Schöning:
> Guten Tag Sven Meier,
> am Mittwoch, 1. April 2015 um 22:54 schrieben Sie:
>
>> why don't you allow null (i.e. #isNullValid() returning true), while
>> setting the DropDownChoice required?
> Because null is not valid in my case and the displayed texts for the
> placeholder label option are different for both null valid vs. invalid
> cases.
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Improve Support for placeholder label option for DropDownChoice?

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Sven Meier,
am Mittwoch, 1. April 2015 um 22:54 schrieben Sie:

> why don't you allow null (i.e. #isNullValid() returning true), while
> setting the DropDownChoice required?

Because null is not valid in my case and the displayed texts for the
placeholder label option are different for both null valid vs. invalid
cases.

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Improve Support for placeholder label option for DropDownChoice?

Posted by Sven Meier <sv...@meiers.net>.
Hi,

why don't you allow null (i.e. #isNullValid() returning true), while 
setting the DropDownChoice required?

That should give you the required placeholder option, doesn't it?

Regards
Sven


Am 01.04.2015 um 20:24 schrieb Thorsten Schöning:
> Hi all,
>
> I got the following error during validation of one of my forms today:
>
>> The first child option element of a select element with a required
>> attribute, and without a multiple attribute, and without a size
>> attribute whose value is greater than 1, must have either an empty
>> value attribute, or must have no text content. Consider either
>> adding a placeholder option label, or adding a size attribute with a
>> value equal to the number of option elements.
> The message is about the following spec:
>
> http://dev.w3.org/html5/spec-preview/the-select-element.html#placeholder-label-option
>
> The reason for the error seems simple: I use a DropDownChoice with a
> default selected value and null disallowed, so I always need a value.
> In that case AbstractSingleSelectChoice.getDefaultChoice doesn't
> provide any content, because there's already one value selected and
> this is not null. That results in the select gets only rendered with
> the choices provided, missing a default option with value "" and so
> violating the HTML5 spec... The default option doesn't necessarily
> needs to be selected, it just needs to exist if the select is
> required.
>
> To resolve this issue I extended DropDownChoice and implemented my own
> getDefaultChoice, which simply always returns an option with value ""
> if the base implementation returns an empty string.
>
> Is this worth creating an issue in JIRA, either as bug or enhancement?
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org