Class DefaultIndexHandler

All Implemented Interfaces:
Handler, RouterNanoHTTPD.UriResponder
Direct Known Subclasses:
PropertiesIndexHandler, RolesIndexHandler, TasksIndexHandler, UsersIndexHandler

public class DefaultIndexHandler extends BaseHandler
Default handler for 'web/html/<entity>/index.html' templates.
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
  • Constructor Details

    • DefaultIndexHandler

      public DefaultIndexHandler(String entity)
      New default index handler.
      Parameters:
      entity - entity
    • DefaultIndexHandler

      public DefaultIndexHandler(String entity, String msg)
      New default index handler.
      Parameters:
      msg - message
      entity - entity
    • DefaultIndexHandler

      public DefaultIndexHandler(String entity, String msg, int messageType)
      New default index handler.
      Parameters:
      msg - message
      entity - entity
      messageType - messagetype
  • 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
    • generateActionsTableData

      public String generateActionsTableData(Session userSession, String entity, Entity entityObj, String modifyID, int dbId, String lang)
      Create actions table data. This must return a HTML <td>...</td> section with all actions possible on the index page. the actions possibly returned might depend on the user's role. This method is internally called by the readData(BeetRootHTTPSession, int) method.
      Parameters:
      userSession - user session
      entity - entity string
      entityObj - entity object
      modifyID - obfuscated modify id used action links
      dbId - internal DB id, don't write it out!
      lang - user's language
      Returns:
      HTML data
    • getDeleteName

      public String getDeleteName(Entity entityObj)
      Get the name/id that should be shown in the delete confirmation dialog.
      Parameters:
      entityObj - entity
      Returns:
      id/name of delete object
    • addAdditionalActions

      public String addAdditionalActions(Session userSession, String entity, String modifyID, int dbId, String lang)
      Add additional actions.
      Parameters:
      userSession - user session
      entity - entity string
      modifyID - obfuscated modify id used action links
      dbId - internal DB id, don't write it out!
      lang - user's language
      Returns:
      HTML data or null
    • changeAllowed

      public boolean changeAllowed(Session userSession)
      Determine if change actions are shown on index page.
      Parameters:
      userSession - user session
      Returns:
      true or false
    • deleteAllowed

      public boolean deleteAllowed(Session userSession)
      Determine if delete actions are shown on index page.
      Parameters:
      userSession - user session
      Returns:
      true or false
    • prepare

      public void prepare(BeetRootHTTPSession session, Entity entity)
      Prepare call to to something with the current entity bean processed in the list if necessary. Called before all extractSingleTableData(BeetRootHTTPSession, ResultSet, String, int, Entity) calls.
      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
    • getPaginator

      public String getPaginator(BeetRootHTTPSession session)
      Get whole index paginator.
      Overrides:
      getPaginator in class BaseHandler
      Parameters:
      session - HTTP session
      Returns:
      HTML paginator code
    • 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