How to override Table Create Action

Hi Team,

Please advise me how can i override the Table Create Action method. So that my collection have only two items. If i click create button it should show that maximum number of items reached for save.

Regards,
Nagendra.

Hi,

you can inject the create action and then define a beforeActionPerformedHandler like this:


class CustomerBrowse extends AbstractLookup {

    @Inject
    CollectionDatasource<Customer, UUID> customerDs;

    @Named("customerTable.create")
    CreateAction createAction;

    @Override
    void init(Map<String, Object> params) {

        createAction.setBeforeActionPerformedHandler(new Action.BeforeActionPerformedHandler() {
            @Override
            boolean beforeActionPerformed() {
                return customerDs.size() < 2;
            }
        });
    }
}

Bye
Mario

3 Likes

Thank you very much

Hi Mario,
I am using the EntityCombinedScreen and i want to override the create button in the screen. I added the code below… But the beforeActionPerformed() function was not triggering plz help me regarding this…

@Named("table.create")
CreateAction createAction;

@Override
public void init(Map<String, Object> params) {

    super.init(params);

    createAction.setBeforeActionPerformedHandler(new Action.BeforeActionPerformedHandler() {
        @Override
        public boolean beforeActionPerformed() {
            return userExtDs.size() < 10;
        }
    });