Data sending from contoller to ui.

Hello,i am developing an application but i am facing the problem to send my data from contoller to UI without using database means i have my data on controller not in database.

Hi,
You need to give your UI component an ID and then inject the UI component into your controller using the same ID name. The code below will set the value of the text field to “Hello” when the screen is loaded.


public class Screen extends AbstractWindow { 
@Inject TextField txtTest; 
@Override 
public void init(Map<String, Object> params) { 
txtTest.setValue("Hello"); 
} 
}

UI

If you are using other components like the data grid, you can link it to a datasource (even if you don’t want to get data from a database).
In your controller, you will need to inject your data source:


@Inject     CollectionDatasource<Property, UUID> propertiesDs;

and then add items to the data source like this:


propertiesDs.addItem(item);

You can always clear the data grid like this:


propertiesDs.clear();