I have a text field called 'dateField' on a form that has an
associated DatePicker control.  When someone selects a date in the
picker, I want to do an ajax call to refresh another component on the
page.  I need the dateField model to be updated in the ajax call.

I originally assumed the model would be updated automatically to the
new value, but it doesn't seem to be.  Now I'm thinking that is
because the form hasn't actually been submitted yet, which makes
sense.

So, how do I get the current value of the dateField inside an
onEvent() handler?  What is the best way to update the dateField's
model with the current value?  I've tried the following, but the model
value remains the same:

dateField.add(new AjaxEventBehavior("onchange") {
  protected void onEvent(AjaxRequestTarget target) {
    // Refresh the ListView
     Logger log = Logger.getLogger(getClass());
     log.debug("Date Changed -- refreshing report");
     setSelectedDate((Date)(getComponent().getModelObject()));
     List<ReportRow> availList = createReportList();
     AvailabilityReportPanel arp = new
AvailabilityReportPanel("availReport", availList);
     ReportForm.this.availReport.replaceWith(arp);
     ReportForm.this.availReport = arp;
     target.addComponent(ReportForm.this.availReport);
   }
});

Note that setSelectedDate() is the setter for the dateField's model.
Also, createReportList() uses getSelectedDate() in an HQL query to
build the List.

What is the proper way to deal with this? Is there a way to indicate
that the form should submit during ajax calls?

Thanks!
Tauren

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to