Create and use Job Results.
The example is based on DemoResultClient
from scala-adapters.
Constraints
- You have created the project with scala-adapters-g8.
- You have your Job ready (server-jobs).
- The Job must create some result (like data from a webservice request).
Shared Data
One of the big advantages of having Scala on the server and the client is that you have to define the data you exchange only once!
So lets create /shared/src/main/scala/shared/GetStartedResult
In essence this needs 2 lines of code:
- Define the Data as a Case Class (this could also be a complex structure of case classes).
- Provide a Json -marshaller/ -un-marshaller.
Client Configuration
The client you use is defined by configuration (see reference.conf
of scala-adapters)
In your get-started Project you have:
We only have to replace "DefaultClient"
to "GetStartedClient"
Create Client
scala-adapters provides a default implementation (client.name = "DefaultClient"
)
Lets create the Client from that: /client/src/main/scala/client/GetStartedClient.scala
We create an implementation for the case JOB_RESULTS =>
:
The Implementation has 2 new elements:
CustomResultsInfos
that defines the header of the result table and a Tooltip for the Result Filter.
GetStartedResultForJobResultsRow
is the Type Class instance for GetStartedResult that is used to create a JobResultsRow.
Here is its implementation:
It creates a row of the Result Table, using predefined elements provided by a Utility.
tdDateTime
is an example on how to customize a table cell.
Adjust the JobProcess
We need 2 things:
First: A Result object that handles filtering and sorting:
Second: A small change in the JobProcess:
Check Result
Running the Project and running the Job, should give you this:
Check your implementation:
- tooltip of the Filter Results..
- header of table
- row of table (the list element of the time)