You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Grigorov (JIRA)" <ji...@apache.org> on 2017/06/19 13:42:00 UTC

[jira] [Commented] (WICKET-6403) DropDownChoice ignores OnChangeAjaxBehavior while setting null value when required is true

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

Martin Grigorov commented on WICKET-6403:
-----------------------------------------

Is JavaScript 'change' event called on the <select> when you select the null value ?
If the JS event is not triggered by the browser then Wicket won't be notified to make its Ajax call with the update.

> 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)