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

Kamil edited comment on WICKET-6403 at 6/20/17 3:18 PM:
--------------------------------------------------------

[~mgrigorov] as I said - all events work fine when "setRequired(true)" is not 
set and I believe that this property is not propagated to HTML, so it is 
something in wicket

[~svenmeier] yes, OnChangeAjaxBehavior#onError is being called, but this should 
not be an "error" since *value in dropdown has been changed* causing 
inconsistency (because value in Model stays old but user thinks that he changed 
the value. This could be ok if JS on the client side would prevent dropdown to 
change)

In my opinion setting "null value" should update the model and call "onUpdate" 
because update on the user side has been allowed and done. If user hits save 
while the value is null - It will just not pass validation error, but this is 
perfectly valid scenario.


was (Author: eximius):
[~mgrigorov] as I said - all events work fine when "setRequired(true)" is not 
set and I believe that this property is not propagated to HTML, so it is 
something in wicket

[~svenmeier] yes, OnChangeAjaxBehavior#onError is being called, but this should 
not be an "error" since *value in dropdown has been changed* causing 
inconsistency (because value in Model stays old but user thinks that he changed 
the value. This could be ok if JS on the client side would prevent dropdown to 
change)

In my opinion seting "null value" should update the model and call "onUpdate" 
because update on the user side has been allowed and done. If user hits save 
while the value is null - It will just not pass validation error, but this is 
perfectly valid scenario.

> DropDownChoice ignores OnChangeAjaxBehavior while setting null value when 
> required is true
> ------------------------------------------------------------------------------------------
>
>                 Key: WICKET-6403
>                 URL: https://issues.apache.org/jira/browse/WICKET-6403
>             Project: Wicket
>          Issue Type: Bug
>    Affects Versions: 8.0.0-M6
>            Reporter: Kamil
>
> I have a simple DropDown with OnChangeAjaxBehavior:
> {code}
> List<String> choices = Arrays.asList("one", "two", "three");
> IModel<String> wicketModel = Model.of();
> DropDownChoice<String> wicketDropDown = new 
> DropDownChoice<>("wicketDropDown",wicketModel , ListModel.of(choices));
> wicketDropDown.add(new OnChangeAjaxBehavior() {
>       @Override
>       protected void onUpdate(AjaxRequestTarget target) {
>               System.out.println("Wicket change: "+wicketModel.getObject());
>       }
> });
> add(wicketDropDown);
> {code}
> onUpdate is called everytime I change the value *even if this value is "null 
> value"*.
> Now when instead of:
> {code}
> add(wicketDropDown);
> {code}
> I set:
> {code}
> add(wicketDropDown.setRequired(true));
> {code}
> onUpdate works on selecting values but *does not work when selecting "null 
> value"* which is wrong. 
> One of the use cases why it is wrong: I have two dropdowns. First dropdown 
> selects _Group_ and second selects _Subgroup_. _Subgroup_ can not be selected 
> if _Group_ is null, though if I select _Group_, then I select _Subgroup_ and 
> then clear the _Group_ - _Subgroup_ should be cleared as well (but I'm not 
> able to do that because onUpdate is not being called).



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to