what do you thin about doing it this way?

I dont know if the onerror() should be invoked if an exception is thrown from onupdate(), i think the user has to do his own exception there.

-Igor


/**
     *
     * @see wicket.ajax.AjaxEventBehavior#onEvent(wicket.ajax.AjaxRequestTarget)
     */
    protected final void onEvent(final AjaxRequestTarget target)
    {
        final FormComponent formComponent = getFormComponent();
        try
        {
            formComponent.inputChanged();
            formComponent.validate();
            if (formComponent.hasErrorMessage())
            {
                formComponent.invalid ();
            }
            else
            {
                formComponent.valid();
                formComponent.updateModel();
            }
        }
        catch (RuntimeException e)
        {
            onError(target, e);
        }
        onUpdate(target);

    }

On 6/1/06, Maurice Marrink < [EMAIL PROTECTED]> wrote:
Hi Igor,

I recently had the need to enhance your
AjaxFormComponentUpdatingBehavior to customize exception handling. Its
just a small modification but you might want to include it in the
wicket source. Here's the new OnEvent method and a new abstract method
to be called when an exception occurs.

Maurice


/**
*
* @see wicket.ajax.AjaxEventBehavior#onEvent(wicket.ajax.AjaxRequestTarget)
*/
protected final void onEvent(final AjaxRequestTarget target)
{
        final FormComponent formComponent = getFormComponent();
        formComponent.inputChanged();
        formComponent.validate();
        if (formComponent.hasErrorMessage())
        {
                 formComponent.invalid();
                onUpdate(target);
        }
        else
        {
                try
                {
                        formComponent.valid();
                         formComponent.updateModel();
                        onUpdate(target);
                }
                catch(RuntimeException e)
                {
                        onError(target, e);
                }
        }
}
/**
* Listener invoked when an exception occurred during the update of
the components model.
* @param target
*/
protected abstract void onError(AjaxRequestTarget target, Exception exception);


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Wicket-develop mailing list
Wicket-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to