Re: wantsOnSelectionChangedNotifications - RadioGroup / Radio vs DropDownChoice
I've just added an issue to JIRA with a quickstart attachment: https://issues.apache.org/jira/browse/WICKET-5596 Cheers Simon -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/wantsOnSelectionChangedNotifications-RadioGroup-Radio-vs-DropDownChoice-tp4665927p4665942.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: wantsOnSelectionChangedNotifications - RadioGroup / Radio vs DropDownChoice
Hi, Sounds like a bug. Please create a quickstart app and attach it to a ticket in JIRA. Thanks! Martin Grigorov Wicket Training and Consulting On Mon, May 19, 2014 at 12:54 PM, Simon B wrote: > Hi, > > I'm using Wicket 6.14.0 > > I've got a form with many components including one which is a RadioGroup > (with several Radio) and one which is a DropDownChoice, > > Both the RadioGroup // Radios and the DropDownChoice have been marked to > get > selection changed notifications with the > RadioGroup#wantOnSelectionChangedNotifications() and the > DropDownChoice#wantOnSelectionChangedNotifications() both returning true. > > My problem is that the DropDownChoice although it refreshes the *page does > not* actually receive a notification via the onSelectionChanged(T) method > whereas the RadioGroup *does* via the onSelectChanged(Object). > > I've looked at the code and noticed that when Wicket (6.14 in my case) > writes out the onChange javascript the radio and the dropdown differ > slightly: > > Here is the html code for both: > > Notably the radio sets a specific form element name "id28_hf_0" to the > value > (reference): > > ./antwerp.web.page.account.realtyadvert.publish.PublishRealtyAdvert?6-1.IOnChangeListener-publishRealtyAdvert-form-advertEditPanel-operationType > and the Dropdown sets the same form element name: > > ../../page?6-1.IOnChangeListener-publishRealtyAdvert-form-advertEditPanel-propertyType > So the first one (of the radio group) works ok and finds the right > ListenerInterfaceRequestHandler and calls its onSelectionChanged() > methodThe > second one (from the dropdown) does not find any > ListenerInterfaceRequestHandler. > The code from DropDownChoice that creates the onchange attribute value is: > // we do not want relative URL here, because it will be used by// > Form#dispatchEventCharSequence url = urlFor(new > ListenerInterfaceRequestHandler(new > PageAndComponentProvider(getPage(), > this, new PageParameters()), > IOnChangeListener.INTERFACE));Form form = > findParent(Form.class);if (form != null){ tag.put("onchange", > form.getJsForInterfaceUrl(url.toString()));}else{ tag.put("onchange", > "window.location.href='" + url + > (url.toString().indexOf('?') > -1 ? "&" : > "?") + getInputName() + "=' + > this.options[this.selectedIndex].value;");} > The code from Radio > // url that points to this components IOnChangeListener methodCharSequence > url = group.urlFor(IOnChangeListener.INTERFACE, new > PageParameters());Form form = group.findParent(Form.class);if (form != > null){ tag.put("onclick", form.getJsForInterfaceUrl(url));}else{ // > NOTE: do > not encode the url as that would give invalid JavaScript > tag.put("onclick", > "window.location.href='" + url + > (url.toString().indexOf('?') > -1 ? "&" : > "?") + group.getInputName() + "=' + > this.value;");} > The page on which the form is on is not mapped its is just redirected to > from another mapped page, I think this may be the problem and I should > explicitly map the page with the form so that both urlFor calls return a > defined page. > > I just tried that mapping the page to "my-advert-form-page.html" and it now > works fine. > > So back to my original question, is this a bug in wicket, or am I just > using > the framework incorrectly. > > Cheers > > Simon > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/wantsOnSelectionChangedNotifications-RadioGroup-Radio-vs-DropDownChoice-tp4665927.html > Sent from the Users forum mailing list archive at Nabble.com. > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
wantsOnSelectionChangedNotifications - RadioGroup / Radio vs DropDownChoice
Hi, I'm using Wicket 6.14.0 I've got a form with many components including one which is a RadioGroup (with several Radio) and one which is a DropDownChoice, Both the RadioGroup // Radios and the DropDownChoice have been marked to get selection changed notifications with the RadioGroup#wantOnSelectionChangedNotifications() and the DropDownChoice#wantOnSelectionChangedNotifications() both returning true. My problem is that the DropDownChoice although it refreshes the *page does not* actually receive a notification via the onSelectionChanged(T) method whereas the RadioGroup *does* via the onSelectChanged(Object). I've looked at the code and noticed that when Wicket (6.14 in my case) writes out the onChange javascript the radio and the dropdown differ slightly: Here is the html code for both: Notably the radio sets a specific form element name "id28_hf_0" to the value (reference): ./antwerp.web.page.account.realtyadvert.publish.PublishRealtyAdvert?6-1.IOnChangeListener-publishRealtyAdvert-form-advertEditPanel-operationType and the Dropdown sets the same form element name: ../../page?6-1.IOnChangeListener-publishRealtyAdvert-form-advertEditPanel-propertyType So the first one (of the radio group) works ok and finds the right ListenerInterfaceRequestHandler and calls its onSelectionChanged() methodThe second one (from the dropdown) does not find any ListenerInterfaceRequestHandler. The code from DropDownChoice that creates the onchange attribute value is: // we do not want relative URL here, because it will be used by// Form#dispatchEventCharSequence url = urlFor(new ListenerInterfaceRequestHandler(new PageAndComponentProvider(getPage(), this, new PageParameters()), IOnChangeListener.INTERFACE));Form form = findParent(Form.class);if (form != null){ tag.put("onchange", form.getJsForInterfaceUrl(url.toString()));}else{ tag.put("onchange", "window.location.href='" + url +(url.toString().indexOf('?') > -1 ? "&" : "?") + getInputName() + "=' + this.options[this.selectedIndex].value;");} The code from Radio // url that points to this components IOnChangeListener methodCharSequence url = group.urlFor(IOnChangeListener.INTERFACE, new PageParameters());Form form = group.findParent(Form.class);if (form != null){ tag.put("onclick", form.getJsForInterfaceUrl(url));}else{ // NOTE: do not encode the url as that would give invalid JavaScript tag.put("onclick", "window.location.href='" + url +(url.toString().indexOf('?') > -1 ? "&" : "?") + group.getInputName() + "=' + this.value;");} The page on which the form is on is not mapped its is just redirected to from another mapped page, I think this may be the problem and I should explicitly map the page with the form so that both urlFor calls return a defined page. I just tried that mapping the page to "my-advert-form-page.html" and it now works fine. So back to my original question, is this a bug in wicket, or am I just using the framework incorrectly. Cheers Simon -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/wantsOnSelectionChangedNotifications-RadioGroup-Radio-vs-DropDownChoice-tp4665927.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org