Default filtering on object

This allows to properly add some default filters that the user can remove

public class DemoSupplier extends ObjectDB {
	private static final long serialVersionUID = 1L;
	private static final String INIT_FILTER_FLAG="supplier_init_filter";
	
	@Override
	public void postLoad() {
		getGrant().setParameter(INIT_FILTER_FLAG, true);
	}
	
	@Override
	public void preSearch() {
		if(getGrant().getBooleanParameter(INIT_FILTER_FLAG, false)){
			getGrant().setParameter(INIT_FILTER_FLAG, false);
			setFieldFilter("demoSupCode", "BIM");	
		}	
	}
}

1 Like

Another way to limit the filtering on the Main instance only and without the postLoad hook:

public class DemoSupplier extends ObjectDB {
	private static final long serialVersionUID = 1L;
	private static final String INIT_FILTER_FLAG="supplier_init_filter";
		
	@Override
	public void preSearch() {
		if (isMaintInstance() && getGrant().getBooleanParameter(INIT_FILTER_FLAG, true)) {
			getGrant().setParameter(INIT_FILTER_FLAG, false);
			setFieldFilter("demoSupCode", "BIM");	
		}	
	}
}