You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Joel Hill <Hi...@michigan.gov> on 2007/09/27 22:36:14 UTC

Ajax error with AjaxFormSubmitBehavior

I'm trying to use AjaxFormSubmitBehavior, and in the ajax debug I'm
getting:

ERROR: Received Ajax response with code: 404

Anyone know what this means?  Nothing in the logs indicates a problem,
but maybe I'm not using AjaxFormSubmitBehavior properly.  I'm trying to
wicketify a javascript-based calendar control I wrote in my pre-wicket
days, since I'm not sure I liked the out-of-the-box implementation of
the date picker (maybe there are some customization options available
for it, I haven't checked).

My CalendarControl class is a FormComponentPanel which contains a
TextField, button (implemented as an AjaxLink) which opens the calendar,
and a ModalWindow which contains the actual calendar.  The ModalWindow
contains a page, which contains a single form.  In the form constructor
I call:

        add(new AjaxFormSubmitBehavior("onsubmit") {
          @Override
          protected void onSubmit(AjaxRequestTarget target) {
            logger.debug("***** Running the onSubmit handler");
            CalendarControl.this.date = formDate;  // Updating the
CalendarControl's model with the form's model data
            target.addComponent(CalendarControl.this);
            calendar.close(target);  // calendar is the ModelWindow
object, obviously
          }
        });

I add the ajax behavior to the form itself, since the calendar page is
created almost entirely in javascript, so I can't really put in wicket
components to fire off the ajax.  I only have a HiddenField component on
the page to capture the selected date so I can get it back to wicket. 
So in order to actually make the ajax request, I have a js function on
the page which calls:

    document.forms[0].onsubmit();

This invokes the onsubmit behavior wicket generates in the form tag.

I know this probably looks a bit hacked, but I was hoping to quickly
reimplement my calendar control in wicket, since it already has the
functionality and style I want.  However, if no one has any handy
solutions, or the solution begins to get overly long and complicated, I
may have to look at what options I have for customizing wicket's date
picker.  The biggest problem I had with it was that you could only move
through the calendar one month at a time, while my control has dropdowns
for both the month and year (although personally, if the date I wanted
was too far from the current date, or whatever default date the calendar
starts on, I would just type it in manually to the TextField).

Any help would be appreciated, as always.  Thanks.

Joel


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org