You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Thomas Heigl <th...@umschalt.com> on 2012/11/06 17:29:56 UTC
Wicket 6.2: Required attribute on ListMultipleChoice has no effect
Hey All,
I noticed that "setRequired(true)" on ListMultipleChoice does not have an
effect anymore after upgrading to Wicket 6 from Wicket 1.5.7.
I think it might be a problem with the ajax library because the AJAX post
request looks like this (where 'tags' is my <select multiple /> field)
tags:null
> :submit:1
The ListMultipleChoice now thinks that the input was non-empty (String
'null') and returns an empty list when converting the value and hence
passes the required check because an empty list is non-null.
@Override
protected Collection<T> convertValue(String[] ids) throws
ConversionException
{
if (ids != null && ids.length > 0 && !Strings.isEmpty(ids[0]))
{
return convertChoiceIdsToChoices(ids);
}
else
{
ArrayList<T> result = new ArrayList<T>();
addRetainedDisabled(result);
return result;
}
}
When I change the component to a simple DropDownChoice the request looks
like this and everything works as expected:
> tags:
> :submit:1
Cheers,
Thomas
Re: Wicket 6.2: Required attribute on ListMultipleChoice has no effect
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
Please create a ticket in Jira with a small quickstart app.
Thanks!
On Tue, Nov 6, 2012 at 6:29 PM, Thomas Heigl <th...@umschalt.com> wrote:
> Hey All,
>
> I noticed that "setRequired(true)" on ListMultipleChoice does not have an
> effect anymore after upgrading to Wicket 6 from Wicket 1.5.7.
>
> I think it might be a problem with the ajax library because the AJAX post
> request looks like this (where 'tags' is my <select multiple /> field)
>
> tags:null
> > :submit:1
>
>
> The ListMultipleChoice now thinks that the input was non-empty (String
> 'null') and returns an empty list when converting the value and hence
> passes the required check because an empty list is non-null.
>
> @Override
> protected Collection<T> convertValue(String[] ids) throws
> ConversionException
> {
> if (ids != null && ids.length > 0 && !Strings.isEmpty(ids[0]))
> {
> return convertChoiceIdsToChoices(ids);
> }
> else
> {
> ArrayList<T> result = new ArrayList<T>();
> addRetainedDisabled(result);
> return result;
> }
> }
>
> When I change the component to a simple DropDownChoice the request looks
> like this and everything works as expected:
>
>
> > tags:
> > :submit:1
>
>
> Cheers,
>
> Thomas
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>