Class DefaultViewHandler

All Implemented Interfaces:
Handler, RouterNanoHTTPD.UriResponder
Direct Known Subclasses:
PropertiesViewHandler, RolesViewHandler, TasksViewHandler, UsersViewHandler

public class DefaultViewHandler extends BaseHandler
Default handler for 'web/html/<entity>/view.html' templates.
  • Constructor Details

    • DefaultViewHandler

      public DefaultViewHandler(String entity)
  • Method Details

    • readData

      public HandlerResponse readData(BeetRootHTTPSession session, int id) throws Exception
      Description copied from class: BaseHandler
      Read data from DB that must be filled when the template is parsed. Used by index and view handlers.
      Overrides:
      readData in class BaseHandler
      Parameters:
      session - HTTP session
      id - db record id > 0 if a single record should be read otherwise < 0;
      Returns:
      response or null, null means success, response's status must be checked!
      Throws:
      Exception - exception
    • prepare

      public void prepare(BeetRootHTTPSession session, Entity entity)
      Prepare call to to something with the entity bean if necessary.
      Parameters:
      session - HTTP session
      entity - entity bean
    • extractSingleTableData

      public String extractSingleTableData(BeetRootHTTPSession session, ResultSet set, String columnName, int idx, Entity entity) throws Exception
      Extract one single table data field from result set standing at current row. NOTE: Never call "set.next()" !
      Parameters:
      session - HTTP session
      set - database result set pointing to current record
      columnName - column name as configured in 'web/<entity>/columns.cfg'
      idx - SQL result set column index
      entity - whole entity bean
      Returns:
      html data extract <td>...</td>
      Throws:
      Exception - exception
    • extractCustomSingleTableData

      public String extractCustomSingleTableData(BeetRootHTTPSession session, ResultSet rsmd, String columnName, int idx, Entity entity) throws Exception
      Overwrite this method, if you need to add a custom data; e.g. when multiple user roles are used; in this case it is more likely that you combine more values that just one field value or use it for any custom value. The value is guaranteed to be inserted in the column-order as defined in the 'columns.cfg'.
      Parameters:
      session - HTTP session
      rsmd - result set meta data
      columnName - column name as configured in 'web/<entity>/columns.cfg'
      idx - SQL result set column index
      entity - whole entity bean
      Returns:
      html data extract <td>...</td>
      Throws:
      Exception - exception
    • getResource

      public String getResource()
      Description copied from class: BaseHandler
      Get web resource file as it lies on the file system relatively to the started server process.
      Specified by:
      getResource in interface Handler
      Specified by:
      getResource in class BaseHandler
      Returns:
      web resource
    • getBeanClass

      public Class<?> getBeanClass()
      Get bean entity class that has been generated trough PLANT, self-written or null (then null in extract calls too).
      Overrides:
      getBeanClass in class BaseHandler
      Returns:
      bean entity class