Package org.onosproject.ui.table
Class TableRequestHandler
- java.lang.Object
-
- org.onosproject.ui.RequestHandler
-
- org.onosproject.ui.table.TableRequestHandler
-
public abstract class TableRequestHandler extends RequestHandler
Message handler specifically for table views.
-
-
Field Summary
-
Fields inherited from class org.onosproject.ui.RequestHandler
MAPPER
-
-
Constructor Summary
Constructors Constructor Description TableRequestHandler(String reqType, String respType, String nodeName)
Constructs a table request handler for a specific table view.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addTableConfigAnnotations(TableModel tm, com.fasterxml.jackson.databind.node.ObjectNode payload)
Adds table configuration specific annotations to table model.protected TableModel
createTableModel()
Creates the table model (devoid of data) usinggetColumnIds()
to initialize it, ready to be populated.protected String
defaultColumnId()
Returns the default column ID to be used when one is not supplied in the payload as the column on which to sort.protected abstract String[]
getColumnIds()
Subclasses should return the array of column IDs with which to initialize their table model.protected abstract String
noRowsMessage(com.fasterxml.jackson.databind.node.ObjectNode payload)
Subclasses should return the message to display in the table when there are no rows to display.protected abstract void
populateTable(TableModel tm, com.fasterxml.jackson.databind.node.ObjectNode payload)
Subclasses should populate the table model by addingrows
.void
process(com.fasterxml.jackson.databind.node.ObjectNode payload)
Processes the incoming message payload from the client.-
Methods inherited from class org.onosproject.ui.RequestHandler
bool, chain, eventType, get, number, sendMessage, sendMessage, string, string
-
-
-
-
Constructor Detail
-
TableRequestHandler
public TableRequestHandler(String reqType, String respType, String nodeName)
Constructs a table request handler for a specific table view. When table requests come in, the handler will generate the appropriate table rows, sort them according the the request sort parameters, and send back the response to the client.- Parameters:
reqType
- type of the request eventrespType
- type of the response eventnodeName
- name of JSON node holding row data
-
-
Method Detail
-
process
public void process(com.fasterxml.jackson.databind.node.ObjectNode payload)
Description copied from class:RequestHandler
Processes the incoming message payload from the client.- Specified by:
process
in classRequestHandler
- Parameters:
payload
- request message payload
-
createTableModel
protected TableModel createTableModel()
Creates the table model (devoid of data) usinggetColumnIds()
to initialize it, ready to be populated.This default implementation returns a table model with default formatters and comparators for all columns.
- Returns:
- an empty table model
-
addTableConfigAnnotations
protected void addTableConfigAnnotations(TableModel tm, com.fasterxml.jackson.databind.node.ObjectNode payload)
Adds table configuration specific annotations to table model.- Parameters:
tm
- a table modelpayload
- the event payload from the client
-
defaultColumnId
protected String defaultColumnId()
Returns the default column ID to be used when one is not supplied in the payload as the column on which to sort.This default implementation returns "id".
- Returns:
- default sort column identifier
-
getColumnIds
protected abstract String[] getColumnIds()
Subclasses should return the array of column IDs with which to initialize their table model.- Returns:
- the column IDs
-
noRowsMessage
protected abstract String noRowsMessage(com.fasterxml.jackson.databind.node.ObjectNode payload)
Subclasses should return the message to display in the table when there are no rows to display. For example, a host table might return "No hosts found".- Parameters:
payload
- request payload- Returns:
- the message
-
populateTable
protected abstract void populateTable(TableModel tm, com.fasterxml.jackson.databind.node.ObjectNode payload)
Subclasses should populate the table model by addingrows
.tm.addRow() .cell(COL_ONE, ...) .cell(COL_TWO, ...) ... ;
The request payload is provided in case there are request filtering parameters (other than sort column and sort direction) that are required to generate the appropriate data.- Parameters:
tm
- the table modelpayload
- request payload
-
-