How to customize a generic edit view

Hello dear Cuba Team,

How to customize a generic edit view of an entity to do following:

  1. add dynamic ui fields during runtime

  2. set values, query / manipulate actions and behavior of the ui fields

Our scenario: An entity has attributes, one attribute is based on an enumeration. For each item of the enumeration we want to add additional ui fields on selection. The values of those fields will be interpreted by usage of other entity attributes.

It would be the best if we could recognize the possibilities by an example.

Hi,

To manipulate UI components you need to inject them into the screen controller and then you will be able to change their properties, obtain values and add listeners.

If you need to tune UI according to some value you can add either ItemPropertyChangeListener to a datasource (if value relates to an entity attribute) or ValueChangeListener to a particular field (if this field isn’t connected to a datasource).

The same rule works for setting values. If your field is connected to a datasource the recommended way is to set the value to an entity field, or set the value to a particular field otherwise.

I’ve prepared a simple demo project with fields depended on selected enum value at GitHub.

Also, there are video recording which you can find helpful:
Develop a fully functional business application within an hour with CUBA Platform
Development Tools Overview

Regards,
Gleb

Thank you for your approach, explanations and example. That was exactly the answer I was looking for.

I’ve one more question.

I plan to have a Browser view with two tables, one main table for customer entities on the top, the table at the bottom contains the order entities. I would like to implement an “click action/listener” within the selection of an customer the content of the order table will be re-/loaded.

How can I implement this kind of Listener or Action?

Is following way recommend:

@Override
public void init(Map<String, Object> params) {
    ((LookupSelectionChangeNotifier) mainTable)
            .addLookupValueChangeListener(new LookupSelectionChangeListener() {
                @Override
                public void lookupValueChanged(LookupSelectionChangeEvent event) {
                    Customer singleSelected = mainTable.getSingleSelected();
                    // fill second table
                }
            });
}

Hi,

As the new question isn’t related to the given topic, could you please create a new one?

Regards,
Gleb

Thanks Gleb, I created How to customize a generic browser view - CUBA.Platform