You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Xavier López <xa...@gmail.com> on 2011/01/26 10:25:58 UTC

Calculate property value on form submission

Hi,

I've got a form with some fields, backed by an entity with a cpm. I've got
one property on the entity which value is calculated in terms of one of the
input fields in the form. It's important to have this field calculated up to
date at form validation time.
I tipically approached this issue by using an
ajaxformcomponentupdatingbehavior to update the entity's calculated field on
every change. Now i'm allowing non-js users into the site, and have mimed
this action with a submit button. But, of course, the user might not press
the button and go straight away without pre-calculating the value
server-side.
I've been thinking about binding a propertymodel to that calculated
property, and somehow make it work like a model, so that its getObject will
calculate the value, and thus have the value calculated before executing the
form validator.
Could you please provide any hint on how tho achieve this, if it is
possible?

Thank you very much!
Xavier

Re: Calculate property value on form submission

Posted by Igor Vaynberg <ig...@gmail.com>.
dont use a cpm, write a model that chains the entity model and does
the right thing in get/set.

-igor

On Wed, Jan 26, 2011 at 1:25 AM, Xavier López <xa...@gmail.com> wrote:
> Hi,
>
> I've got a form with some fields, backed by an entity with a cpm. I've got
> one property on the entity which value is calculated in terms of one of the
> input fields in the form. It's important to have this field calculated up to
> date at form validation time.
> I tipically approached this issue by using an
> ajaxformcomponentupdatingbehavior to update the entity's calculated field on
> every change. Now i'm allowing non-js users into the site, and have mimed
> this action with a submit button. But, of course, the user might not press
> the button and go straight away without pre-calculating the value
> server-side.
> I've been thinking about binding a propertymodel to that calculated
> property, and somehow make it work like a model, so that its getObject will
> calculate the value, and thus have the value calculated before executing the
> form validator.
> Could you please provide any hint on how tho achieve this, if it is
> possible?
>
> Thank you very much!
> Xavier
>

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