Database connection from Client screen / Service

Hi everyone.
I need to create a report only if a user clicks a button on a screen.
Is there a way to get a connection to the database from a Screen Controller? Or the way is create a service that creates the report on the given input and return it to the controller?

Hi Federico,

the latter one is correct. You just define a service that gets executed in the middleware block (core module). In the controller you’ll just inject the service and call the corresponding method.

An example of this you’ll find here:

  • [url=]DeepLinkServiceBean[/url] (core module)
  • [url=]DeepLinkService Interface[/url] (global module)
  • [url=]Controller that uses the service[/url] (gui module)
As you see [url=]here[/url] you can pass parameters from the controller and get results back.

Are you talking about the report facility from CUBA? In this case, you should have a look at this section in the docs on how to run a report from a screen.

You can also work with data on the client tier through DataManager, as in this example.