Hi,

>Just move formComponent.valid() inside if (getUpdateModel())

good.

>I think #onValid() is not used that much. What is your observation ?

I really don't know.

>Otherwise we can use reflection to call just #onValid() in 'else' branch.

I wouldn't do that: Just add a hint to #getUpdateModel(), so users know that they'll have to call #valid() *and* #updateModel() if they return false.

Sven


On 08/06/2014 11:16 AM, Martin Grigorov wrote:
FromComponent#updateModel() javadoc says:

Updates this components model from the request, it expects that the object
is already
converted through the convertInput() call that is called by the validate()
method when a form
is being processed.

that's why I think it is the best place to clear the form component's
second model - the rawInput.
But you are right that at the moment there is no check in place that
super.updateModel() is called and even fixing all places in Wicket's code
there is no guarantee that it won't fail in users' applications.

Here is what I propose as a simpler fix:
Just move formComponent.valid() inside if (getUpdateModel())
the drawback is that FormComponent#onValid() won't be called if the model
is not updated.
I think #onValid() is not used that much. What is your observation ?

Otherwise we can use reflection to call just #onValid() in 'else' branch.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov


On Mon, Aug 4, 2014 at 9:37 PM, Sven Meier <[email protected]> wrote:

Hi Martin,

we have components overriding #updateModel() (without calling super).
You'd have to call #clearInput() from these places too :/.

I don't think it belongs into #updateModel() - the method does not
indicate that it has anything to do with 'raw input'.
Yes, neither does #valid() :P.

Regards
Sven



On 08/04/2014 05:20 PM, Martin Grigorov wrote:

Hi,

Looking at https://issues.apache.org/jira/browse/WICKET-5658 I start to
agree with the reporter that Wicket does it a bit wrong here.

AjaxFormComponentUpdatingBehavior has the following code:

if (formComponent.isValid())
{
formComponent.valid();
   if (getUpdateModel())
{
formComponent.updateModel();
   }

It calls formComponent.valid() (that internally calls #clearInput() and
#onValid()) and then calls formComponent.updateModel() if it is allowed to
do so (see https://issues.apache.org/jira/browse/WICKET-992).
What I find incorrect is that #clearInput() is called by #valid().
I think #clearInput() should be called by #updateModel() instead. I.e.
only
when the converted input is stored as a model we should drop the raw
input.

Do you see a problem with such change ?


Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov



Reply via email to