Package ch.autumo.beetroot.handler
Class DefaultEditHandler
java.lang.Object
org.nanohttpd.router.RouterNanoHTTPD.DefaultStreamHandler
org.nanohttpd.router.RouterNanoHTTPD.DefaultHandler
ch.autumo.beetroot.handler.BaseHandler
ch.autumo.beetroot.handler.DefaultEditHandler
- All Implemented Interfaces:
Handler,RouterNanoHTTPD.UriResponder
- Direct Known Subclasses:
PropertiesEditHandler,RolesEditHandler,TasksEditHandler,UsersEditHandler
Default handler for 'web/html/<entity>/edit.html' templates.
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.autumo.beetroot.handler.BaseHandler
BaseHandler.IfSectionHandler -
Field Summary
Fields inherited from class ch.autumo.beetroot.handler.BaseHandler
action, columns, emptyBean, entity, htmlData, htmlHead, initialValues, insertServletNameInTemplateRefs, MSG_TYPE_ERR, MSG_TYPE_INFO, MSG_TYPE_WARN, PRECISION_INPUT_TYPES, servletName, TAG_PREFIX_LANG, transientFields, uniqueFields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultEditHandler(String entity) DefaultEditHandler(String entity, String errMsg) -
Method Summary
Modifier and TypeMethodDescriptionextractCustomSingleInputDiv(BeetRootHTTPSession session, String val, ResultSetMetaData rsmd, String columnName, String guiColName, int idx) Overwrite this method, if you need to add a custom field (HTML 'div'); e.g. when multiple user roles are used; in this case the 'div' is more likely consisting of 2 role assignment boxes instead of a simple input-'div' or use it for any custom 'div'.protected StringextractSingleInputDiv(BeetRootHTTPSession session, ResultSet set, Entity entity, String columnName, String guiColName, int sqlType, int idx) Extract one single input div with label and input tags from result set standing at current row.protected StringextractSingleInputDiv(BeetRootHTTPSession session, Map<String, String> data, ResultSetMetaData rsmd, String columnName, String guiColName, int idx) Extract one single input div with label and input tags from result set standing at current row.formatSingleValueForDB(BeetRootHTTPSession session, String val, String columnname) Format single value before update / insert into DB.formatSingleValueForGUI(BeetRootHTTPSession session, Object dbObject, String preformattedValue, String columnName, int sqlType, int dbIdx, Entity entity) Format value for GUI.Class<?>Get bean entity class that has been generated trough PLANT, overwritten or null.Get web resource file as it lies on the file system relatively to the started server process.protected String[]getSelectValues(String columnName) Get values for column nameprotected booleanIs this column a HTML select field?voidprepare(BeetRootHTTPSession session, Entity entity) Prepare call to to something with the entity bean if necessary.readData(BeetRootHTTPSession session, int id) Read data from DB that must be filled when the template is parsed.updateData(BeetRootHTTPSession session, int id) Update data in DB.Methods inherited from class ch.autumo.beetroot.handler.BaseHandler
addCheckBox, addErrorMessage, addHtmlDataLine, addHtmlHeadLine, addSuccessMessage, addWarningMessage, columns, columnsSize, deleteData, get, getColumn, getColumnsForSql, getColumnsForSql, getCurrentEntityDbId, getCurrentSession, getCustomizedExceptionInformation, getData, getEmptyBean, getEntity, getHandlerClass, getHtmlData, getHtmlHead, getInsertValues, getLayout, getMessageType, getMimeType, getNewScanner, getNewScanner, getPaginator, getRedirectHandler, getSimpleManagementUserRoles, getStatus, getTableExport, getTemplateEngineErrorMessage, getTemplateEngineErrorTitle, getText, getText, getTitle, getTransientFields, getUpdateSetClause, getUpdateSetClause, hasAccess, hasExternalLinks, hasNoColumnsConfig, initialize, initialValue, initValuesSize, isCurrentUserUpdate, isCustomResponse, isNoContentResponse, isNoContentResponseButRoute, isPrecisionInputType, isRetryCall, loginMarker, parseAssociatedEntities, parseUnassociatedEntities, patchInputValue, readSnippetResource, redirectedMarker, refreshUserRoles, registerDisplayField, registerRoutes, render, renderAll, saveData, setCurrentEntityDbId, setMessageType, setVar, setVarAll, showLangMenu, showMenu, uniqueFields, uniqueTestMethods inherited from class org.nanohttpd.router.RouterNanoHTTPD.DefaultStreamHandler
delete, other, post, put
-
Constructor Details
-
DefaultEditHandler
-
DefaultEditHandler
-
-
Method Details
-
readData
Description copied from class:BaseHandlerRead data from DB that must be filled when the template is parsed. Used by index and view handlers.- Overrides:
readDatain classBaseHandler- Parameters:
session- HTTP sessionid- 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
-
updateData
Description copied from class:BaseHandlerUpdate data in DB. Override for edit handlers.- Overrides:
updateDatain classBaseHandler- Parameters:
session- HTTP sessionid- db record id- Returns:
- response or null, null means success, response's status must be checked!
- Throws:
Exception- exception
-
prepare
Prepare call to to something with the entity bean if necessary.- Parameters:
session- HTTP sessionentity- entity bean
-
extractSingleInputDiv
protected String extractSingleInputDiv(BeetRootHTTPSession session, ResultSet set, Entity entity, String columnName, String guiColName, int sqlType, int idx) throws Exception Extract one single input div with label and input tags from result set standing at current row. NOTE: Never call "set.next()" !- Parameters:
session- HTTP sessionset- result set holding one recordentity- entity beancolumnName- column name as configured in 'web/<entity>/columns.cfg'guiColName- GUI column name as configured in 'web/<entity>/columns.cfg'sqlType- SQL type, seeTypesidx- SQL result set column index- Returns:
- html data extract <div>...</div>
- Throws:
Exception- exception
-
extractSingleInputDiv
protected String extractSingleInputDiv(BeetRootHTTPSession session, Map<String, String> data, ResultSetMetaData rsmd, String columnName, String guiColName, int idx) throws ExceptionExtract one single input div with label and input tags from result set standing at current row. NOTE: Never call "set.next()" ! Called in the retry case; 'data' contains cached data from previous user input.- Parameters:
session- HTTP sessiondata- repost datarsmd- result set meta datacolumnName- column name as configured in 'web/<entity>/columns.cfg'guiColName- GUI column name as configured in 'web/<entity>/columns.cfg'idx- SQL result set column index- Returns:
- html data extract <div>...</div>
- Throws:
Exception- exception
-
extractCustomSingleInputDiv
public String extractCustomSingleInputDiv(BeetRootHTTPSession session, String val, ResultSetMetaData rsmd, String columnName, String guiColName, int idx) throws Exception Overwrite this method, if you need to add a custom field (HTML 'div'); e.g. when multiple user roles are used; in this case the 'div' is more likely consisting of 2 role assignment boxes instead of a simple input-'div' or use it for any custom 'div'. The 'div' is guaranteed to be inserted in the column-order as defined in the 'columns.cfg'.
The return value of this method is essential:
- Returns the data (including an empty character string): The HTML data is inserted into the template and further parsing of the columns for the HTML input elements is completed.
- If 'null' is returned, the search for matching input elements for the current columns is continued, even if it is a transient column! Transient columns should be parsed in this method!
- Parameters:
session- HTTP sessionval- repost data (only available in retry case)rsmd- result set meta datacolumnName- column name as configured in 'web/<entity>/columns.cfg'guiColName- GUI column name as configured in 'web/<entity>/columns.cfg'idx- SQL result set column index- Returns:
- html data extract <div>...</div>, empty string or null
- Throws:
Exception- exception
-
isSelect
Is this column a HTML select field?- Parameters:
columnName- column name- Returns:
- true if so
-
getSelectValues
Get values for column name- Parameters:
columnName- column name- Returns:
- select vaues
-
formatSingleValueForGUI
public String formatSingleValueForGUI(BeetRootHTTPSession session, Object dbObject, String preformattedValue, String columnName, int sqlType, int dbIdx, Entity entity) Format value for GUI.- Parameters:
session- HTTP sessiondbObject- DB objectpreformattedValue- pre-formatted database valuecolumnName- DB column namesqlType- SQL type, seeTypesdbIdx- SQL result set column indexentity- whole entity bean- Returns:
- formated value for given column-name or DB index
-
formatSingleValueForDB
Description copied from class:BaseHandlerFormat single value before update / insert into DB. This method is useful if you want to store null values for date, time or time-stamp in the database. In the HTML user interface, the value would be displayed as '' (empty string), which is not a valid value in the database; in this case, it would need to be set to null. This is rarely the case, as date/time values are normally set or, if they are mandatory, should be set in theDefaultAddHandler.getAddMandatoryFields()method when creating a new record. It is therefore only possible for updates.- Overrides:
formatSingleValueForDBin classBaseHandler- Parameters:
session- HTTP sessionval- valuecolumnname- column name- Returns:
- formatted value
-
getResource
Description copied from class:BaseHandlerGet web resource file as it lies on the file system relatively to the started server process.- Specified by:
getResourcein interfaceHandler- Specified by:
getResourcein classBaseHandler- Returns:
- web resource
-
getBeanClass
Get bean entity class that has been generated trough PLANT, overwritten or null.- Overrides:
getBeanClassin classBaseHandler- Returns:
- bean entity class
-