Processing between different fields of a form

Use ValueChangeEvent listener for fields. In the listener, check the necessary fields and fill in other fields.

....

        <form id="form" dataContainer="newEntityDc">
            <column width="350px">
                <textField id="field1Field" property="field1"/>
                <textField id="sumWithDiscount"/>
            </column>
        </form>
......

    @Autowired
    private TextField sumWithDiscount;

    @Subscribe("field1Field")
    public void onField1FieldValueChange(HasValue.ValueChangeEvent<Integer> event) {
        if (event.isUserOriginated() && event.getValue() != null) {
            sumWithDiscount.setValue(event.getValue()*0.9);
        }
    }

In a form i have 2 entitypicker. However the second entitypicker depends on the selection of the first entity. I tried to define a collection with an own loader (query with a paramater) but then I stuck where to set the value from the first entitypicker.

Look at facet dataLoadCoordinator in mamual mode. Often this is very usefull.

But note that the EntityPicker does not have the ability to filter for options.
That is, he will always show all the entities to choose. And for a dependent picker, you need to use EntityComboBox or EntitySuggestionField.

If the dataLoadCoordinator does not match, then again - listener of the ValueChangeEvent event for main EntityPicker. And in the event listener, change the query parameters to load the data into dependent EntityComboBox options container.

1 Like