Table column validator / focus questions

In recent version of CUBA there is a new feature added to change the focus to specific column of the record as follows that works nicely in many cases.

orderLineTable.requestFocus(line, "requestedDeliveryDate");

Now I want to add a Validator/listener in the table column based on the content of another column. I am trying something like this but seems not right…

orderLineDs.addItemPropertyChangeListener(e -> {
	if ("account".equals(e.getProperty())) {
		if (e.getItem().getAccount().getHavingSubAccount() == Boolean.TRUE) {
			// set focus on the first cell of the added row
			bankTranLineTable.requestFocus(e.getItem(), "accountSub");
	} else if ("accountSub".equals(e.getProperty())) {
		if (e.getItem().getAccount().getHavingSubAccount() == Boolean.TRUE) {
			if (e.getItem().getAccountSub() == null) {
				showMessageDialog("Incorrect Data entry", "Please select the sub-account", MessageType.WARNING);

In this case, the focus is not moving from Account to AccountSub when I press the Tab button for example. This might be because of using ItemPropertyChangeListener. Any suggested listener I should use so that even the item is not changed, this works for validation?


When you press Tab and you have changed value inside of Table cell then this value will be applied and ItemPropertyChangeListener will be fired.

I do not recommend to validate Table values on-the-fly because it can lead to poor usability. Use preCommit method instead and validate all items of Table. See:

1 Like