Table column refresh

HI All,
I created an entity with one transient attribute. I create getter and setter method.
For example I have quantity, single value and total value as transient attribute.
I create a browser of this entity enabled in edit mode with quantity and value modificable.
I need to generate total value refresh (transient attribute) when I change one of quantity or single value field.
How can I do it?
I wouldn’t want to call updating of all datasource table for refresh a single column.

You can subscribe to attribute value change event and set the total value field value in this handler. For example, below is a part of the code for calculating visit cost based on its duration and used consumables. Th code is used in the editor screen.

    @Subscribe(id = "visitDc", target = Target.DATA_CONTAINER)
    public void onVisitDcItemPropertyChange(InstanceContainer.ItemPropertyChangeEvent<Visit> event) {
        if (event.getProperty().equals("hoursSpent")) {
            refreshAmount();
        }
    }

    @Subscribe(id = "consumablesDc", target = Target.DATA_CONTAINER)
    public void onConsumablesDcCollectionChange(CollectionContainer.CollectionChangeEvent<Consumable> event) {
        if (event.getChangeType() != CollectionChangeType.REFRESH) {
            refreshAmount();
        }
    }

    private void refreshAmount() {
        Visit visit = getEditedEntity();
        visit.setAmount(visitService.calculateAmount(visit));
    }

Hi Andrey,
thank you for response but I need to update field column in a table.
I have a browse with table editable.
I need to update total value field in table when I change quantity o single value.

Hi,

You can subscribe to ItemPropertyChangeEvent generated by the collection container. and use event.getItem() metod to get edited entity. Did you try it?

Hi Andrey,
I tried your suggest, but my problem is’t get or set value of transient property but refresh screen table.
In my column generator code I set my property “Total value” correctly. The value is setting but on screen table the value isn’t repaint.

Hi,

Could you attach a small possible example please? One entity with the calculated property should be enough.

Sorry Andrey for late
I resolved problem.
I looked that column generator are called more than one time for each row.
I don’t know the reason.
However I changed code and now It’s ok.

1 Like