Re: RadioChoice keeps null rawInput after required validation?
Just in case it helps someone else, we've finally managed to understand why we needed to call clearInput() on rc1 after changing its model object, with help from this previous post http://apache-wicket.1842946.n4.nabble.com/Ajax-and-form-handling-and-clearInput-td1866836.html(thanks Alexander, Igor) 1. When selecting 'no' and submitting the form without providing a value to rc1, the required validation prevents form submission. An empty string remains as rc1's rawinput as that's the last user inputted value. 2. When selecting 'yes', an ajax updating behavior fires on the yes/no radiochoice. Rc1's rawInput remains empty. 3. In the behavior's onUpdate(), we set rc1's model object by means of only modifying the backing entity (it had a propertymodel). This is the key point, we weren't aware that rc1#setModelObject() would clear input automatically by calling modelChanged(). 4. At render time, rc1#getValue() got the empty input that the last form submission left, and using that one to set the selected option. Oh, my, I've been thinking this whole time that setModelObject() was equivalent to doing getModel().setObject(). Have to say maybe fooled by setModelObject()'s javadoc 'Sets the backing model object; shorthand for getModel().setObject(object).' Cheers, Xavier 2011/1/26 Igor Vaynberg igor.vaynb...@gmail.com clearinput() is a good way to deal with it, but the component should still set no_raw_input if it is submitted in a disabled state. please file a jira issue, preferably with a quickstart. -igor On Wed, Jan 26, 2011 at 3:05 AM, Xavier López xavil...@gmail.com wrote: Hi, I've got a form with a required radiochoice to select among some options. I've also got a yes/no radiochoice that selects a given option on rc1 and disables it when 'yes' is selected. When 'no' is selected, rc1 is set to enabled and its model object is cleared. The enabling/disabling of rc1 and its modelobject set is done in the onUpdate() method of an AjaxFormChoiceComponentUpdatingBehavior on the yes/no radiochoice. It's working fine, except in the following situation: 'no' is selected and rc1 has no value set. Then the required validation prevents the form submission. After that, if I select 'yes' on the yes/no radiochoice, it enables rc1 and sets its model object successfully, but, to my surprise, the input type=radio has no value selected when rendering the HTML. After debbuging through rc1#onComponentTagBody(), I've found that getValue() returns null, because rawInput is null (and not NO_RAW_INPUT), that's why there's no radio selected. I suspect rawInput is null because of last submitting rc1 with no value selected (when the required validation fails). I managed to get around this by calling rc1.clearInput() on the ajax behavior. Just want to know if i'm right about these thoughts, because I feel something wrong here, and if calling clearInput() is a good way of dealing with this. Thank you for your feedback! Xavier - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: RadioChoice keeps null rawInput after required validation?
2011/2/3 Xavier López xavil...@gmail.com Have to say maybe fooled by setModelObject()'s javadoc 'Sets the backing model object; shorthand for getModel().setObject(object).' My fault, didn't see this has already been addressed on https://issues.apache.org/jira/browse/WICKET-2113 , and is specific of 1.3. Cheers, Xavier
RadioChoice keeps null rawInput after required validation?
Hi, I've got a form with a required radiochoice to select among some options. I've also got a yes/no radiochoice that selects a given option on rc1 and disables it when 'yes' is selected. When 'no' is selected, rc1 is set to enabled and its model object is cleared. The enabling/disabling of rc1 and its modelobject set is done in the onUpdate() method of an AjaxFormChoiceComponentUpdatingBehavior on the yes/no radiochoice. It's working fine, except in the following situation: 'no' is selected and rc1 has no value set. Then the required validation prevents the form submission. After that, if I select 'yes' on the yes/no radiochoice, it enables rc1 and sets its model object successfully, but, to my surprise, the input type=radio has no value selected when rendering the HTML. After debbuging through rc1#onComponentTagBody(), I've found that getValue() returns null, because rawInput is null (and not NO_RAW_INPUT), that's why there's no radio selected. I suspect rawInput is null because of last submitting rc1 with no value selected (when the required validation fails). I managed to get around this by calling rc1.clearInput() on the ajax behavior. Just want to know if i'm right about these thoughts, because I feel something wrong here, and if calling clearInput() is a good way of dealing with this. Thank you for your feedback! Xavier
Re: RadioChoice keeps null rawInput after required validation?
clearinput() is a good way to deal with it, but the component should still set no_raw_input if it is submitted in a disabled state. please file a jira issue, preferably with a quickstart. -igor On Wed, Jan 26, 2011 at 3:05 AM, Xavier López xavil...@gmail.com wrote: Hi, I've got a form with a required radiochoice to select among some options. I've also got a yes/no radiochoice that selects a given option on rc1 and disables it when 'yes' is selected. When 'no' is selected, rc1 is set to enabled and its model object is cleared. The enabling/disabling of rc1 and its modelobject set is done in the onUpdate() method of an AjaxFormChoiceComponentUpdatingBehavior on the yes/no radiochoice. It's working fine, except in the following situation: 'no' is selected and rc1 has no value set. Then the required validation prevents the form submission. After that, if I select 'yes' on the yes/no radiochoice, it enables rc1 and sets its model object successfully, but, to my surprise, the input type=radio has no value selected when rendering the HTML. After debbuging through rc1#onComponentTagBody(), I've found that getValue() returns null, because rawInput is null (and not NO_RAW_INPUT), that's why there's no radio selected. I suspect rawInput is null because of last submitting rc1 with no value selected (when the required validation fails). I managed to get around this by calling rc1.clearInput() on the ajax behavior. Just want to know if i'm right about these thoughts, because I feel something wrong here, and if calling clearInput() is a good way of dealing with this. Thank you for your feedback! Xavier - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org