org.melati.admin
Class Admin

Package class diagram package Admin
java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.melati.servlet.ConfigServlet
              extended by org.melati.servlet.PoemServlet
                  extended by org.melati.servlet.TemplateServlet
                      extended by org.melati.admin.Admin
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class Admin
extends TemplateServlet

Melati template servlet for database administration.

This class defines doTemplateRequest(Melati, ServletTemplateContext) and methods it calls to interpret requests, depending on the current table and object, if any.

Java methods with names ending "Template" and taking a ServletTemplateContext and Melati as arguments are generally called by doTemplateRequest(Melati, ServletTemplateContext)) to implement corresponding request methods. modifyTemplate(ServletTemplateContext, Melati) and associated methods are slight variations.

adminTemplate(String) is called in all cases to return the template path. The name of the template is usually the same as the request method but not if the same template is used for more than one method or the template served depends on how request processing proceeds.

These methods are called to modify the context:

TODO Review working of where clause for dates TODO Move Nav icons into PrimarySelect TODO Make Chooser JS agnostic TODO Make Navigation JS agnostic TODO Logout fails to work if remember me is ticked TODO Order by field f orders on fields troid, not field ordering TODO Enable non-paged output of selection by adding paged parameter to selectionTemplate FIXME primaryDisplayTable should not be static as this messes with DB switching

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.melati.servlet.TemplateServlet
templateEngine
 
Fields inherited from class org.melati.servlet.ConfigServlet
melatiConfig, sysAdminEmail, sysAdminName
 
Constructor Summary
Admin()
           
 
Method Summary
protected static String addTemplate(ServletTemplateContext context, Melati melati)
          Returns the Add template after placing the table and fields for the new row in the context using any field values already in the context.
protected static String addUpdateTemplate(ServletTemplateContext context, Melati melati)
          Returns the Updated template after creating a new row using field data in the context.
protected static String adminTemplate(String name)
          Return the resource path for an admin template.
protected static Persistent create(Table table, ServletTemplateContext context)
          Creates a row for a table using field data in a template context.
protected static String deleteTemplate(ServletTemplateContext context, Melati melati)
           
protected  String doTemplateRequest(Melati melati, ServletTemplateContext context)
          Override this method to build up your own output.
protected static String dsdTemplate(ServletTemplateContext context)
           
protected static String duplicateTemplate(ServletTemplateContext context, Melati melati)
           
protected static String modifyTemplate(ServletTemplateContext context, Melati melati)
          Implements request method "Update".
protected static ServletTemplateContext popupSelect(ServletTemplateContext context, Melati melati)
           
protected static String popupSelectTemplate(ServletTemplateContext context, Melati melati)
          Implements the field search/selection request method.
protected static String primarySelectTemplate(ServletTemplateContext context, Melati melati)
           
protected static ServletTemplateContext selection(ServletTemplateContext context, Melati melati, boolean paged)
          Modifies the context in preparation for serving a template to view a selection of rows.
protected static String selectionRightTemplate(ServletTemplateContext context, Melati melati)
          Implements request to display a selection of records from a table in the right hand pane.
protected static String selectionTemplate(ServletTemplateContext context, Melati melati)
          Return template for a selection of records from a table.
protected static String selectionWindowPrimarySelectTemplate(ServletTemplateContext context, Melati melati)
           
protected static String selectionWindowSelectionTemplate(ServletTemplateContext context, Melati melati)
           
protected static String setupTemplate(ServletTemplateContext context, Melati melati)
           
protected static String updateTemplate(ServletTemplateContext context, Melati melati)
          Returns the Updated template after modifying the current row according to field values in the context.
protected static String uploadDoneTemplate(ServletTemplateContext context)
          Finished uploading.
protected static String uploadTemplate(ServletTemplateContext context)
           
 
Methods inherited from class org.melati.servlet.TemplateServlet
addExtension, doPoemRequest, error, init, prePoemSession
 
Methods inherited from class org.melati.servlet.PoemServlet
_handleException, destroy, doConfiguredRequest, getSysAdminEmail, getSysAdminName, handleException, poemContext, poemContextWithLDB
 
Methods inherited from class org.melati.servlet.ConfigServlet
doGet, doPost, httpStatusCode, melatiConfig, setSysAdminEmail, setSysAdminName, writeConnectionPendingException, writeError
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Admin

public Admin()
Method Detail

create

protected static Persistent create(Table table,
                                   ServletTemplateContext context)
Creates a row for a table using field data in a template context.


adminTemplate

protected static String adminTemplate(String name)
Return the resource path for an admin template.


dsdTemplate

protected static String dsdTemplate(ServletTemplateContext context)
Returns:
a DSD for the database

primarySelectTemplate

protected static String primarySelectTemplate(ServletTemplateContext context,
                                              Melati melati)
                                       throws PoemException
Returns:
primary select template
Throws:
PoemException

selectionTemplate

protected static String selectionTemplate(ServletTemplateContext context,
                                          Melati melati)
Return template for a selection of records from a table.


selectionRightTemplate

protected static String selectionRightTemplate(ServletTemplateContext context,
                                               Melati melati)
Implements request to display a selection of records from a table in the right hand pane.

Returns:
SelectionRight template.

selection

protected static ServletTemplateContext selection(ServletTemplateContext context,
                                                  Melati melati,
                                                  boolean paged)
Modifies the context in preparation for serving a template to view a selection of rows.

Any form fields in the context with names starting "field_" are assumed to hold values that must be matched in selected rows (if not null).

An encoding of the resulting whereClause is added to the context. "AND" is replaced by an & separator.

A form field with name "start" is assumed to hold the number of the start row in the result set. The default is zero. The next 20 rows are selected and added as to the context as "results".

Returns:
The modified context.

popupSelectTemplate

protected static String popupSelectTemplate(ServletTemplateContext context,
                                            Melati melati)
                                     throws PoemException
Implements the field search/selection request method.

Throws:
PoemException

popupSelect

protected static ServletTemplateContext popupSelect(ServletTemplateContext context,
                                                    Melati melati)
                                             throws PoemException
Throws:
PoemException

selectionWindowPrimarySelectTemplate

protected static String selectionWindowPrimarySelectTemplate(ServletTemplateContext context,
                                                             Melati melati)
                                                      throws PoemException
Returns:
primary select template
Throws:
PoemException

selectionWindowSelectionTemplate

protected static String selectionWindowSelectionTemplate(ServletTemplateContext context,
                                                         Melati melati)
Returns:
select template (a selection of records from a table)

addTemplate

protected static String addTemplate(ServletTemplateContext context,
                                    Melati melati)
                             throws PoemException
Returns the Add template after placing the table and fields for the new row in the context using any field values already in the context. If the table is a table meta data table, or a column meta data table then the appropriate extras are added to the co0ntext. The Form does not normally contain values, but this could be used as a mechanism for providing defaults.

Throws:
PoemException

addUpdateTemplate

protected static String addUpdateTemplate(ServletTemplateContext context,
                                          Melati melati)
                                   throws PoemException
Returns the Updated template after creating a new row using field data in the context.

If successful the template will say so while reloading according to the returnTarget and returnURL values from the Form in context.

Throws:
PoemException

updateTemplate

protected static String updateTemplate(ServletTemplateContext context,
                                       Melati melati)
                                throws PoemException
Returns the Updated template after modifying the current row according to field values in the context.

If successful the template will say so while reloading according to the returnTarget and returnURL values from the Form in context.

Throws:
PoemException

deleteTemplate

protected static String deleteTemplate(ServletTemplateContext context,
                                       Melati melati)
                                throws PoemException
Throws:
PoemException

duplicateTemplate

protected static String duplicateTemplate(ServletTemplateContext context,
                                          Melati melati)
                                   throws PoemException
Throws:
PoemException

modifyTemplate

protected static String modifyTemplate(ServletTemplateContext context,
                                       Melati melati)
                                throws FormParameterException
Implements request method "Update".

Calls another method depending on the requested action.

Throws:
FormParameterException
See Also:
updateTemplate(ServletTemplateContext, Melati), deleteTemplate(ServletTemplateContext, Melati), duplicateTemplate(ServletTemplateContext, Melati)

uploadTemplate

protected static String uploadTemplate(ServletTemplateContext context)
                                throws PoemException
Throws:
PoemException

uploadDoneTemplate

protected static String uploadDoneTemplate(ServletTemplateContext context)
                                    throws PoemException
Finished uploading. If you want the system to display the file you need to set your melati-wide FormDataAdaptorFactory, in org.melati.MelatiConfig.properties, to something that returns a valid URL, for instance, PoemFileDataAdaptorFactory; (remember to set your UploadDir and UploadURL in the Setting table).

Parameters:
context - the ServletTemplateContext in use
Returns:
a template name
Throws:
PoemException

setupTemplate

protected static String setupTemplate(ServletTemplateContext context,
                                      Melati melati)

doTemplateRequest

protected String doTemplateRequest(Melati melati,
                                   ServletTemplateContext context)
                            throws Exception
Description copied from class: TemplateServlet
Override this method to build up your own output.

Specified by:
doTemplateRequest in class TemplateServlet
Parameters:
melati - the current Melati
context - the current ServletTemplateContext
Returns:
a Template name, possibly excluding extension.
Throws:
Exception


Copyright © 2000-2010 PanEris. All Rights Reserved.