You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by ChambreNoire <aw...@tentelemed.com> on 2015/11/23 20:43:44 UTC

Difficulty with related, mutually updating fields

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.

+ If a user removes the value of the calculated field, it just gets
recalculated.

+ If a user changes the value of the calculated field (for a valid value),
the other field is blanked and is updated with a calculated value - it
becomes the calculated field.

+ If a user enters an invalid value into the calculated field this results
in a feedback error and the non-calculated field doesn’t update.

+ Similarly, if the user enters an invalid value into the non-calculated
field the feedback error is shown and the calculated field is NOT updated
(it remains based on the previous valid non-calculated field value).

+ It would be nice to be able to chain these fields – have another duration
/ end date couple which use the first couple’s end date (calculated or not)
as a start date. 

Any pointers would be most appreciated as I’m having trouble seeing this
clearly…

Thanks,

CN


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Difficulty-with-related-mutually-updating-fields-tp4672701.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
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
>
>

Re: Difficulty with related, mutually updating fields

Posted by Tobias Gierke <to...@voipfuture.com>.
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