I am a beginner, so sorry for silly questions.
I have read the documentation, but for me there aren’t enough example and not really clear.
In my project the user can select more rows in Customers browse screen. And after it user should click my EditStatusBtn. First I want to check if any row has selected, but it isn’t run with that code:
public class CustomerBrowse extends AbstractLookup {
@Inject
protected Table<Customer> table;
public void onEditStatusBtn(Component source) {
if (table.getSelected().isEmpty()) {
showNotification("Select detail rows first", NotificationType.HUMANIZED);
return;
}
}
}
I think that better option for you is to use ItemTrackingAction.
First of all you should add an action and a button into your Table component in screen descriptor:
Let’s have a look an attributes of action and button.
trackSelection=“true” disables a button linked to this action if any row is not selected.
invoke=“editStatus” means that after clicking the button method with name editStatus will be executed.
action=“customersTable.editStatus” links button and action. It means that clicking the button leads to the action perform.
Here is example of screen controller with code which will be executed after clicking the button:
@Inject
private Table<Customer> customersTable;
public void editStatus() {
Customer customer = customersTable.getSingleSelected();
// there is no need in checking that customer is not null if you use ItemTrackingAction
String message = String.format("Customer %s %s was selected", customer.getFirstName(), customer.getLastName());
showNotification(message);
}
Szabó Eszter, the simpliest variant is to invoke your method “editStatus” and check if there are selected rows in your table, ItemTrackingAction supports only single selection mode.