On Thu, Feb 17, 2011 at 6:50 PM, Pedro Santos <[email protected]> wrote:
> I Daniel, how alwaysUpdateModel differs from updateModel?
You mean "from getUpdateModel()"? isAlwaysUpdateModel() is called only
when component is invalid, but getUpdateModel() in both cases (for
valid and invalid).
> If you have an
> required form component that support some clean up logic, it can be coded
> inside AjaxFormComponentUpdatingBehavior#onError, and if you need an AJAX
> behavior that don't validate the form component, you can
> use AjaxEventBehavior instead of AjaxFormComponentUpdatingBehavior.
Yes. Of course I can create my own behavior by doing a copy of
original AjaxFormComponentUpdatingBehavior and changing some code
inside onEvent() method. But then I will have my own class hierarchy,
very similar to original one. And always after upgrading Wicket to a
new version I'll have to check if something was changed in original
classes. The second reason to have this in core is that I think these
use-cases are very common.
Placing my code in onError() is not a good solution, because component
is prior marked as invalid and has an error message (which cause
displaying it in FeedbackPanel).
> The code you sent will end up invoking formComponent.valid() for non valid
> components, it is problematic.
You have right. So maybe this code should looks like below (changing
valid state only when validation is enabled):
{
formComponent.inputChanged();
if (!isDisabledValidation) {
formComponent.validate();
}
if (formComponent.hasErrorMessage())
{
formComponent.invalid();
if (isAlwaysUpdateModel()) {
if (getUpdateModel())
{
formComponent.updateModel();
}
}
onError(target, null);
}
else
{
if (!isDisabledValidation) {
formComponent.valid();
}
if (getUpdateModel())
{
formComponent.updateModel();
}
onUpdate(target);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]