Passing values from textfield and a dateField to screen controller

I have a custom search screen from where I need to pass in the search criteria to the controller.

For example: I have a mobile Registration screen where I need to search for all registrations done for

  1. an email - (a Text Field)
  2. between From and To dates (dateField).

I need to pass on these fields to my controller.

Please note that i tried:




Please advise.

Hi, you can use following approach:
You can add Map of parameters to all method that open new window (openWindow(), openEditor(), openLookup()…) and then read them from Controller in init() method from variable params.

Example:
openWindow("calendar", WindowManager.OpenType.NEW_TAB, ParamsMap.of("task", Table.getSingleSelected(), "mode", CalendarModeEnum.TASK));

In calendar screen:
@Override
public void init(Map<String, Object> params) {
CalendarModeEnum calendarMode = (CalendarModeEnum) params.get("mode")
};

Anything that is done is init() method of the controller happens before screen rendering.

My question is about passing user input/selected values to the controller.

I am sorry I did not understand your question correctly. Can you post more concrete example what you want to achieve?

Could you clarify what do you mean by

input values to the controller?

Do you need to set initial values to the newly created entity? Or update values of editing entity before screen is opened?

Let me try and elaborate the question a little further.

Please consider this:
I have a web page where the user can supply input criteria:

  1. An input field (textField in the context of CUBA platform) for email ID
  2. Two date fields representing start/end dates(dateField in the context of CUBA platform)

User clicks on search button on the page.
I want the extract the values in these fields in my controller (the Java class corresponding to the screen in CUBA platform).
The intent is to use these values to perform DB search using middleware in CUBA platform.

Please revert in case this is still not clear.

Hi,

Take a look at these docs:

Also, could be helpful:

Hi,
Did you find the solution? I got a same question as you. I don’t think the solution given here can solve your issue.

Hi,

when I understand the requirement correctly, you have a text input field, 2 date input fields and a search button in your screen.

To use these values in your controller after pressing the button do the following:

For all fields and the button give them a id, e.g searchButton, fromDate, toDate, searchText
For the button you also define an invoke method, e.g. onSearchButtonClick

Now in your controller you need to inject all these fields and the button
In your button click method you can then access the values of the fields and do e.g. your search in your service…

You should take a closer look on the documentation for button and how the controller can access data from screen elements.

CU
Steven