Re: Reacting to DateField change
On Thu, 9 Aug 2007 17:18:37 +0200 Federico Fanton [EMAIL PROTECTED] wrote: In 1.3 DatePicker was replaced with DateField, they are completely different components.. I will try with your suggestion ASAP though, thanks again :) I tried with DateField field = ... field.add(new AjaxFormComponentUpdatingBehavior(onchange){ protected void onUpdate(AjaxRequestTarget target) { // do stuff } }); The original relevant HTML is span wicket:id=endDate/ while the resulting HTML is span wicket:id=endDate name=endDate onchange=var wcall=wicketAjaxPost('?wicket:interface=:10:frmSearch:endDate::IBehaviorListener:0:', wicketSerialize(Wicket.$('endDate7')), function() { }.bind(this), function() { }.bind(this)); id=endDate7 wicket:panel span style=white-space: nowrap; input value= type=text wicket:id=date size=8 name=endDate:date id=date2/ spannbsp;div style=display:none;z-index: 9;position:absolute; id=date2Dp/div img style=cursor: pointer; border: none; id=date2Icon src=resources/org.apache.wicket.extensions.yui.calendar.DatePicker/icon1.gif //span input type=hidden/ /span /wicket:panel /span So, the onchange is bound to the span element.. Maybe I should use a different markup in my HTML? I'd like the event to fire when I select a date from the popup calendar.. Many thanks again for your attention! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reacting to DateField change
are you using trunk? in earlier versions of trunk you had to override DatePicker#notifyComponentOnDateSelected to return true. now it returns true by default. don't worry too much about the javascript code generated by DatePicker, it should work well. also, DateField consists of a DateTextField and automatically adds a DatePicker behavior to that DateTextField, but you can provide your own DateTextField (e.g. with an added AjaxFormComponentUpdatingBehavior(onchange) ) by overriding DateField#newDateTextField(String, PropertyModel) hth, gerolf On 8/21/07, Federico Fanton [EMAIL PROTECTED] wrote: On Tue, 21 Aug 2007 11:58:19 +0200 Federico Fanton [EMAIL PROTECTED] wrote: So, the onchange is bound to the span element.. Maybe I should use a different markup in my HTML? I'd like the event to fire when I select a date from the popup calendar.. I see that the code for the datepicker popup contains // fire onchange notification if (wasVisible false) { YAHOO.util.Dom.get(date2).onchange(); } So maybe I should bind the behavior to the textfield instead (date2 is its id) and.. Well, figure out what that false is about X-) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reacting to DateField change
On Tue, 21 Aug 2007 12:50:32 +0200 Gerolf Seitz [EMAIL PROTECTED] wrote: are you using trunk? No, beta2 in earlier versions of trunk you had to override DatePicker#notifyComponentOnDateSelected to return true. Great, now everything is ok! :) also, DateField consists of a DateTextField and automatically adds a DatePicker behavior to that DateTextField, but you can provide your own DateTextField (e.g. with an added AjaxFormComponentUpdatingBehavior(onchange) ) by overriding DateField#newDateTextField(String, PropertyModel) I see.. When beta3 ships I'll change my code to use the new method. Many thanks :) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Reacting to DateField change
Hi everyone! I'd like to add an AJAX behavior to a DateField, so that when the value of the textfield changes an event gets fired.. I went with something like field.get(date).add(new Mybehavior(onchange)) to attach the event to the textfield, but (comprehensibly) it doesn't get fired when I change the date via the calendar.. Any hint? ^^; Many thanks for your attention - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reacting to DateField change
On Thu, 9 Aug 2007 14:10:58 +0100 Dipu Seminlal [EMAIL PROTECTED] wrote: Did you add onchange in the markup as well, you need to add it in the markup as well input wicket:id=yourDate id=yourDate type=text name=yourDate onchange=blah / I'm sorry, do you mean that Wicket replaces the blah on the fly? I thought that behaviors don't need modification to the markup.. Or maybe it's needed just for DateFields? I'll try with your suggestion though, many thanks :) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reacting to DateField change
Don't you need to setOutputMarkupId(true) as well on the component? On 8/9/07, Federico Fanton [EMAIL PROTECTED] wrote: On Thu, 9 Aug 2007 14:10:58 +0100 Dipu Seminlal [EMAIL PROTECTED] wrote: Did you add onchange in the markup as well, you need to add it in the markup as well input wicket:id=yourDate id=yourDate type=text name=yourDate onchange=blah / I'm sorry, do you mean that Wicket replaces the blah on the fly? I thought that behaviors don't need modification to the markup.. Or maybe it's needed just for DateFields? I'll try with your suggestion though, many thanks :) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reacting to DateField change
yes i am almost certain, we need to have the event in the markup. if you add an onchange behaviour then you must add onchange in the markup. On 8/9/07, Federico Fanton [EMAIL PROTECTED] wrote: On Thu, 9 Aug 2007 14:10:58 +0100 Dipu Seminlal [EMAIL PROTECTED] wrote: Did you add onchange in the markup as well, you need to add it in the markup as well input wicket:id=yourDate id=yourDate type=text name=yourDate onchange=blah / I'm sorry, do you mean that Wicket replaces the blah on the fly? I thought that behaviors don't need modification to the markup.. Or maybe it's needed just for DateFields? I'll try with your suggestion though, many thanks :) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reacting to DateField change
oh yes you need to set the outputMakupId to true, here you go TextField dateField = new TextField(dateField); add(dateField); final TextField updatedField = new TextField(updatedField); updatedField.setOutputMarkupId(true); add(updatedField); AjaxFormComponentUpdatingBehavior behavior = new AjaxFormComponentUpdatingBehavior(onchange) { protected void onUpdate(AjaxRequestTarget target) { testModel.setUpdatedField(newValue); // set the new value to the backing model repaint the component target.addComponent(updatedField); } }; dateField.add(behavior); input wicket:id=dateField type=text value= text onchange=blah/ input wicket:id=updatedField type=text value= text / On 8/9/07, Dipu Seminlal [EMAIL PROTECTED] wrote: yes i am almost certain, we need to have the event in the markup. if you add an onchange behaviour then you must add onchange in the markup. On 8/9/07, Federico Fanton [EMAIL PROTECTED] wrote: On Thu, 9 Aug 2007 14:10:58 +0100 Dipu Seminlal [EMAIL PROTECTED] wrote: Did you add onchange in the markup as well, you need to add it in the markup as well input wicket:id=yourDate id=yourDate type=text name=yourDate onchange=blah / I'm sorry, do you mean that Wicket replaces the blah on the fly? I thought that behaviors don't need modification to the markup.. Or maybe it's needed just for DateFields? I'll try with your suggestion though, many thanks :) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reacting to DateField change
On Thu, 9 Aug 2007 15:34:03 +0100 Dipu Seminlal [EMAIL PROTECTED] wrote: oh yes you need to set the outputMakupId to true, here you go TextField dateField = new TextField(dateField); D'oh! I'm sorry, I fear I didn't explain myself properly :( The DateField I'm using is the date picker widget used by Wicket 1.3.. It's a FormComponentPanel made of a textfield and an icon which - when clicked - pops up a calendar.. So, I attached my behavior to the textfield and it works when I change the textfield directly, but I don't know how to intercept when _the calendar_ changes the textfield.. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reacting to DateField change
i just tried with the date picker on 1.2.6 and it works, don't know if anything has changed drastically in 1.3 see the code below DatePickerSettings datePickerSettings = new DatePickerSettings(); datePickerSettings.setIfFormat(%d/%m/%Y); datePickerSettings.setStyle(datePickerSettings.newStyleAqua()); TextField dateField = new TextField(dateField); add(dateField); add(new DatePicker (datePicker,dateField)); final TextField updatedField = new TextField(updatedField); updatedField.setOutputMarkupId(true); add(updatedField); AjaxFormComponentUpdatingBehavior behavior = new AjaxFormComponentUpdatingBehavior(onchange) { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { testModel.setUpdatedField(testModel.getDateField()); target.addComponent(updatedField); } }; dateField.add(behavior); input wicket:id=dateField type=text value= text onchange=blah/span wicket:id=datePicker/span input wicket:id=updatedField type=text value= text / On 8/9/07, Federico Fanton [EMAIL PROTECTED] wrote: On Thu, 9 Aug 2007 15:34:03 +0100 Dipu Seminlal [EMAIL PROTECTED] wrote: oh yes you need to set the outputMakupId to true, here you go TextField dateField = new TextField(dateField); D'oh! I'm sorry, I fear I didn't explain myself properly :( The DateField I'm using is the date picker widget used by Wicket 1.3.. It's a FormComponentPanel made of a textfield and an icon which - when clicked - pops up a calendar.. So, I attached my behavior to the textfield and it works when I change the textfield directly, but I don't know how to intercept when _the calendar_ changes the textfield.. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reacting to DateField change
On 8/9/07, Dipu Seminlal [EMAIL PROTECTED] wrote: yes i am almost certain, we need to have the event in the markup. if you add an onchange behaviour then you must add onchange in the markup. no, you do not -igor On 8/9/07, Federico Fanton [EMAIL PROTECTED] wrote: On Thu, 9 Aug 2007 14:10:58 +0100 Dipu Seminlal [EMAIL PROTECTED] wrote: Did you add onchange in the markup as well, you need to add it in the markup as well input wicket:id=yourDate id=yourDate type=text name=yourDate onchange=blah / I'm sorry, do you mean that Wicket replaces the blah on the fly? I thought that behaviors don't need modification to the markup.. Or maybe it's needed just for DateFields? I'll try with your suggestion though, many thanks :) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reacting to DateField change
i checked and i agree with Igor :) On 8/9/07, Igor Vaynberg [EMAIL PROTECTED] wrote: On 8/9/07, Dipu Seminlal [EMAIL PROTECTED] wrote: yes i am almost certain, we need to have the event in the markup. if you add an onchange behaviour then you must add onchange in the markup. no, you do not -igor On 8/9/07, Federico Fanton [EMAIL PROTECTED] wrote: On Thu, 9 Aug 2007 14:10:58 +0100 Dipu Seminlal [EMAIL PROTECTED] wrote: Did you add onchange in the markup as well, you need to add it in the markup as well input wicket:id=yourDate id=yourDate type=text name=yourDate onchange=blah / I'm sorry, do you mean that Wicket replaces the blah on the fly? I thought that behaviors don't need modification to the markup.. Or maybe it's needed just for DateFields? I'll try with your suggestion though, many thanks :) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reacting to DateField change
On Thu, 9 Aug 2007 16:43:45 +0100 Dipu Seminlal [EMAIL PROTECTED] wrote: i checked and i agree with Igor :) Ok, thanks anyway :) So.. Markup modification isn't needed, but if I'm not mistaken attaching the behavior directly to the DateField doesn't yield what I'm looking for..? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reacting to DateField change
On 8/9/07, Federico Fanton [EMAIL PROTECTED] wrote: On Thu, 9 Aug 2007 16:00:24 +0100 Dipu Seminlal [EMAIL PROTECTED] wrote: i just tried with the date picker on 1.2.6 and it works, don't know if anything has changed drastically in 1.3 In 1.3 DatePicker was replaced with DateField, they are completely different components.. I will try with your suggestion ASAP though, thanks again :) DateField is mainly a convenience implementation of a text field + date picker. It is trivial to just use the date picker directly though: myDateTextField.add(new DatePicker()); Regarding receiving those events, this is in 1.3's DatePicker component: /** * Whether to notify the associated component when a date is selected. * Notifying is done by calling the associated component's onchange * Javascript event handler. You can for instance attach an * [EMAIL PROTECTED] AjaxEventBehavior} to that component to get a call back to the * server. The default is true. * * @return if true, notifies the associated component when a date is * selected */ protected boolean notifyComponentOnDateSelected() { return true; } Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reacting to DateField change
Ok, thanks anyway :) So.. Markup modification isn't needed, but if I'm not mistaken attaching the behavior directly to the DateField doesn't yield what I'm looking for..? Nope. That is because the DateField itself is a panel, while you need to attach it to the text field it embeds. In your case, just do: TextField t = new TextField(... t.add(new DatePicker()); t.add(myAjaxBehavior) Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]