PAJES 3.0.21

org.pajes.db.entity
Class DefaultEditor

java.lang.Object
  extended by org.pajes.db.entity.MaintenanceDisplayElement
      extended by org.pajes.db.entity.Viewer
          extended by org.pajes.db.entity.Editor
              extended by org.pajes.db.entity.DefaultEditor
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class DefaultEditor
extends Editor

Abstract super-class of all classes that create a Paje to edit or display an Entity object.

All sub-classes MUST have a no-parameter constructor.

See Also:
Serialized Form

Field Summary
static java.lang.String EDITOR_FACTORY
          The name of the ServletContext attribute that can contain a PajeFactory instance that will generate generic forms for displaying and editing Entity objects.
 
Constructor Summary
DefaultEditor()
           
 
Method Summary
protected  HTML getCancelButton(Form form, InputHidden action)
          Returns the HTML object that will allow the user to exit the Viewer.
protected  HTML getDeleteButton(Form form, InputHidden action)
          Returns the HTML object that will allow the user to delete the Entity being edited.
protected  Form getForm()
          Returns the Form that can be used to display and/or edit an Entity.
 Paje getPaje()
          Returns a Paje to display and/or edit an Entity object.
protected  HTML getSaveButton(Form form, InputHidden action)
          Returns the HTML object that will allow the user to save changes to the Entity being edited.
protected  void setEditorFactory(PajeFactory editor)
          Sets the Editor factory object.
 
Methods inherited from class org.pajes.db.entity.Editor
build, init, isNew, retrieve, setRequest
 
Methods inherited from class org.pajes.db.entity.Viewer
getEntity, getScope, init, setRequest
 
Methods inherited from class org.pajes.db.entity.MaintenanceDisplayElement
clone, getManager, getRequest, getServletContext, init, init, isInitialised
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EDITOR_FACTORY

public static final java.lang.String EDITOR_FACTORY
The name of the ServletContext attribute that can contain a PajeFactory instance that will generate generic forms for displaying and editing Entity objects.

See Also:
Constant Field Values
Constructor Detail

DefaultEditor

public DefaultEditor()
Method Detail

getPaje

public Paje getPaje()
             throws java.io.IOException
Returns a Paje to display and/or edit an Entity object.

The Paje to be returned will be determined as follows:

  1. If a Editor has been defined, it will be requested to create a document.
  2. if noEditor has been defined, the ServletContext will be searched for an attribute named EDITOR_FACTORY, and the object returned by ServletContext.getAttribute will be requested to create a document. Context default Editor factory objects should be created in your Initialisation sub-class.
  3. if no Entity- or context- specific document has been created, a default document will be created.

Once a document has been instantiated, the Container identified by ViewerTemplate.ENTITY_CONTAINER_ID will be retrieved. If this container is empty, the Form returned by getForm() will be added to the container.

The Entity used to populate the input form will be placed into the HttpSession with the following method call:

 
 
 request.getSession().setAttribute(this.getManager().getPrimaryKeyValues(entity), entity);
 
 

For compatibility with PAJES 2.1.x, the Entity will also be placed into the HttpSession with the following method call:

 
 
 request.getSession().setAttribute(this.getManager().getAdminServletName(), entity);
 
 

Specified by:
getPaje in class Viewer
Returns:
a new Paje object.
Throws:
java.io.IOException - if an IO exception occurs.
See Also:
Viewer.build(org.pajes.html.TraversableElement)

getCancelButton

protected HTML getCancelButton(Form form,
                               InputHidden action)
Returns the HTML object that will allow the user to exit the Viewer.

The default implementation returns a SubmitButton with the value "Cancel".

Parameters:
form - the form on which the object will be placed.
action - the hidden field, named MaintenanceServlet.ACTION_PARAMETER, that must be updated with MaintenanceServlet.CANCEL_ACTION_VALUE when this item is selected by the user
Returns:
the HTML object that will allow the user to exit the Viewer.

getDeleteButton

protected HTML getDeleteButton(Form form,
                               InputHidden action)
Returns the HTML object that will allow the user to delete the Entity being edited.

The default implementation returns a SubmitButton with the value "Delete".

Parameters:
form - the form on which the object will be placed.
action - the hidden field, named MaintenanceServlet.ACTION_PARAMETER, that must be updated with MaintenanceServlet.DELETE_ACTION_VALUE when this item is selected by the user
Returns:
the HTML object that will allow the user to delete the Entity being edited.

getForm

protected Form getForm()
                throws java.io.IOException
Returns the Form that can be used to display and/or edit an Entity. All fields will be displayed, except those where Attributes.getEditorPosition() returns a number less than zero.

Note that this method should return a new instance with each invocation, either by direct creation or by cloning. Under no circumstances should one instance be returned mulitple times.

Returns:
the Form
Throws:
java.io.IOException - if an IO exception occurs.

getSaveButton

protected HTML getSaveButton(Form form,
                             InputHidden action)
Returns the HTML object that will allow the user to save changes to the Entity being edited.

The default implementation returns a SubmitButton with the value "Save".

Parameters:
form - the form on which the object will be placed.
action - the hidden field, named MaintenanceServlet.ACTION_PARAMETER, that must be updated with MaintenanceServlet.UPDATE_ACTION_VALUE when this item is selected by the user
Returns:
the HTML object that will allow the user to save changes to the Entity being edited.

setEditorFactory

protected void setEditorFactory(PajeFactory editor)
Sets the Editor factory object.

Parameters:
editor - the Editor factory object.

PAJES 3.0.21

Copyright © 1998-2007 Viridian Pty Limited. All Rights Reserved.