How to update fieldgroup property using a Datasource?


Hi Guys,

I have a metaproperty that will return the calculated manhours.
Do you have any idea how to update fieldgroup property for manhours?

Thank you.

Hello, @Earl02

Do you mean how to use a result of the getCalcmanhrs() method in FieldGroup?


HI @tsarev,

I want to persist the result of getCalcmanhrs either to the datasource manhrs field or on the fieldgroup manhrs. But i have no idea how to do it. Do you have any idea? Can you share it :slight_smile:

It seems that you just should make the calcmanhrs field not transient and use it in FieldGroup.


Hi @tsarev,

I already have a manhrs field for it. So i need the result of calcmanhrs to be pass on manhrs field.

I’ve realized what you want to do and here is a solution.

First of all, you don’t need your transient calcmanhrs field.

The only thing you should do to solve your problem is to add ValueChangeListener's for the startTime and endTime fields in entity editor screen, calculate a value and update the manhrs field:

private TextField startTimeField;

private TextField endTimeField;

public void ready() {

// method parameter is added to be able to use this method as ValueChangeListeners for the time fields
private void updateManHours(ValueChangeEvent ignored) {
    if (startTimeField.getValue() == null || endTimeField.getValue() == null) {

    Double startTime = startTimeField.getValue();
    Double endTime = endTimeField.getValue();

    getItem().setManHours(endTime - startTime);

Here is a small demo project for your case: (74.9 KB)


Hi @tsarev,

Yeah its working fine. So i have another question when you should use metaproperty?

You should use the @MetaPropety annotation when you want to declare that some transient field or method should be included into entity metadata to use it later, for example, in FieldGroup or Table.

Hi @tsarev,

I see, Thank you very much for the support :slight_smile: until next time…
Have a nice day.


I tried to follow your code but it shows compile error. It shows “Unable to find the symbol TimeField”. I think I miss importing a package for “TimeField”. Could you share the name of the package? Thank you.

Hi @thomaslei

TimeField is a fieldgroup type as time.





Thank you. This works well but my case is a little bit different.

Well in your case you should get the time from your timestamp & put it into another variable for you to be able manipulate it.

I tried to get the start date , start time , end date and end time like below but it shows error.
IllegalArgumentException: Can not set com.haulmont.cuba.gui.components.TimeField field com.tupperware.wocompletion.web.ccswo.CcsWoEdit.endTimeField to com.haulmont.cuba.web.gui.components.WebDateField

    private TimeField startTimeField;

    private TimeField endTimeField;
    private DateField startDateField;

    private DateField endDateField;