You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Tobias Gierke <to...@voipfuture.com> on 2015/12/03 14:48:26 UTC

Re: Difficulty with related, mutually updating fields

Hi,
> Hello,
>
> I have a form with the following fields : start date, duration (in days) &
> end date. I want the user to be able to enter EITHER a duration OR an end
> date and the other field will be automatically calculated according to this
> and the start date. Each field has an associated feedback label. However,
> simple as this seems, I’m having trouble pulling it off. Here’s what I’m
> going for in terms of behaviour:
>
> + If the start date is missing, the others are blanked and disabled.
>
> + Changing either field results in an ajax update of both and the other
> field is calculated.
>
> + When the form is submitted, the “calculated” field must be null (even
> though it displays the calculated value). The underlying domain object
> should have either a duration or an end date but not both.
Just curious... why does your domain object need to have both end date 
and duration (either of which can be derived from the other assuming the 
start date is set) ? IMHO this makes things more complicated/error prone 
than necessary (since you have to make sure duration & end date fields 
stay in sync while deriving one from the other would take care of this 
automagically).

Cheers,
Tobias



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


Re: Difficulty with related, mutually updating fields

Posted by Mihir Chhaya <mi...@gmail.com>.
Hi,

It seems having custom validator along with Ajax Events (change/update)
applied on both fields might be helpful to achieve your goal.

Again, as Tobias has mentioned, your scenario could be possibly simplified
by just allowing either Duration or End Date and have that controlled by
some type of radio button selection. You could then have your custom
validator to check if the value entered is valid number, and if it is in
date format then it is valid date.

The calculated value in this case would be then simply a label with
whatever you want to show (as duration or date).

-Mihir.



On Thu, Dec 3, 2015 at 8:48 AM, Tobias Gierke <to...@voipfuture.com>
wrote:

> Hi,
>
>> Hello,
>>
>> I have a form with the following fields : start date, duration (in days) &
>> end date. I want the user to be able to enter EITHER a duration OR an end
>> date and the other field will be automatically calculated according to
>> this
>> and the start date. Each field has an associated feedback label. However,
>> simple as this seems, I’m having trouble pulling it off. Here’s what I’m
>> going for in terms of behaviour:
>>
>> + If the start date is missing, the others are blanked and disabled.
>>
>> + Changing either field results in an ajax update of both and the other
>> field is calculated.
>>
>> + When the form is submitted, the “calculated” field must be null (even
>> though it displays the calculated value). The underlying domain object
>> should have either a duration or an end date but not both.
>>
> Just curious... why does your domain object need to have both end date and
> duration (either of which can be derived from the other assuming the start
> date is set) ? IMHO this makes things more complicated/error prone than
> necessary (since you have to make sure duration & end date fields stay in
> sync while deriving one from the other would take care of this
> automagically).
>
> Cheers,
> Tobias
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>