I have a One-to-One relation between two entities and I use a Lookup Field in order to select the appropriate rows. The problem is that I have an enumeration field and the user should can choose only particular values (see below).
<query>
<![CDATA[select e from abc_Customer e where e.test = 'A' ]]>
</query>
This works for the first button (arrow) but if I press “Open a lookup screen button” the user can see whole table.
Override the default picker_lookup action behavior to pass a specific parameter “testValue” to CustomerBrowse screen. You can find an example of use in the documentation
Delegate data loading to customersDlLoadDelegate function in CustomerBrowse. If the “testValue” parameter is passed, then it is taken into account when loading data. You can find an example of use in the documentation
public class CustomerBrowse extends StandardLookup<Customer> {
@WindowParam
private String testValue;
@Inject
private DataManager dataManager;
@Install(to = "customersDl", target = Target.DATA_LOADER)
private List<Customer> customersDlLoadDelegate(LoadContext<Customer> loadContext) {
if (testValue != null) {
loadContext = loadContext.setQuery(
LoadContext.createQuery("select e from abc_Customer e where e.test = :testValue")
.setParameter("testValue", testValue));
}
return dataManager.loadList(loadContext);
}
}
Using delegates, you can provide code that will be used by various screen mechanisms instead of their standard implementations. For example, you can provide your own function to load data or to set the row icon provider for the table and much more.
You can see the entire list of delegates for the screen controller in the Install Delegate tab using the CUBA Studio.
Each delegate in the window is provided with a description on the right which is extracted from the framework Javadocs.