Calculation logic in UI Form and in POJO Layer?

Hello,

we have a application with a form, where users can enter costs on different rows.
As they go to the next field, the total should be calculated and shown in a separate textfield.
That’s no problem so far, it works.

But we have the same calculations done in the POJO layer, providing the business logic layer.

Is there a way, to have the calculations been done via POJO, but still have the bound textfields etc. be updated as the user switches from field to field?
It’s “nasty” to do this on the UI with onValueChange listener and handling the buffering/writethrough.
Finally it duplicates the calculation code.

I have attached a sample form.
We use JPAContainer for the databinding.

18512.png

Well, you need to notify the UI somehow about the changes, there’s no way to avoid that.
Here’s my solution
to notifying POJO-level modifications to the UI level. I guess you can do that in many ways.

…and if using JPAContainer, I hope you have noticed
the section on refreshing the container or item
if an entity is changed outside the container API.

Thanks, it’s more or less what I did already,
and yes, we use JPAContainer