This solution is bad because it is not generic enough to allow working with any @BrowserCallable/@Endpoint that implements ListService and CountService.
Furthermore, is there any utility on the Hilla side to provide a Java Filter (second parameter of list) based on the params.filter user input? As you see in above code, it is currently undefined.
Could please you provide an example on how to do this the Vaadin way? Especially as generic as possible to be compatible with any @BrowserCallable/@Endpoint that implements ListService and CountService.
Do not that using the Filter class here is in no way mandatory. It is intended as a way for the client side to provide filtering information to the endpoint, e.g. when you have a grid with filtering components in the header cells.
Thank you very much! That was very helpful! Two more question:
Is it possible to debounce the input before sending a server request? Right now, two requests are sent on every key stroke, which might be cumbersome if many users are typing. Maybe adding a 500-800ms delay after the typing has stopped before making a server request would be better.
The code above is good when used in a create form. However, in an edit form, the combobox has to be preloaded with the corresponding data. Let’s say an employee is edited and the departmentId is set inside the form. Searching for departments is possible and setting the departmendId of the employee is also possible. However, when first loading the page, the departmentid ComboBox has to be pre-filled with the corresponding department. How would one do this?
Not quite eagerly. I want the current value of the entity to be preselected if there is any. Changing that value of the entity should still be accomplished with lazy loading, as there might be thousands of values to choose from.