Karel Krajca created WICKET-5311:
------------------------------------

             Summary: Logical collision between setRequired() and 
setNullValid() methods in DropDownChoice
                 Key: WICKET-5311
                 URL: https://issues.apache.org/jira/browse/WICKET-5311
             Project: Wicket
          Issue Type: Improvement
          Components: wicket
    Affects Versions: 6.8.0
            Reporter: Karel Krajca


In my opinion, there is a collision between setRequired() and setNullValid() 
methods in DropDownChoice. Imagine you have an optional property A assigned a 
value in your model. In UI you allow the property A mapped to an instance of 
DropDownChoice to have its value from a list (Item1, Item2). When you adjust 
the instance of DropDownChoice to be DropDownChoice.setRequired(false), you 
expect to have ((none), Item1, Item2) in the dropdown list but in reality, you 
get only (Item1, Item2) choices. To have the (any) option which stands for a 
null value in the dropdown, you still need to set 
DropDownChoice.setNullValid(false).

I would propose to automatically add the "(none)" or "any" value to 
DropDownChoice list when having DropDownChoice.setRequired(false).

Another case showing that setRequired() and setNullValid() are logically 
contradicted is that you can set DropDownChoice.setRequired(true) and 
DropDownChoice.setNullValid(true) leading to have a dropdown with "(any)" 
option which can be selected, but don not pass the form validation.

Thank you for your consideration of this issue which could lead you to some 
useful refactoring.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to