PAJES 2.3.9

org.pajes.db.entity
Class DefaultViewer

java.lang.Object
  extended byorg.pajes.db.entity.MaintenanceDisplayElement
      extended byorg.pajes.db.entity.Viewer
          extended byorg.pajes.db.entity.DefaultViewer
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class DefaultViewer
extends Viewer

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 VIEWER_FACTORY
          The name of the ServletContext attribute that can contain a PajeFactory instance that will generate generic forms for displaying Entity objects.
 
Constructor Summary
DefaultViewer()
           
 
Method Summary
protected  HTML getCancelButton(Form form, InputHidden action)
          Returns the HTML object that will allow the user to exit the Viewer.
 Paje getPaje()
          Returns a Paje to display and/or edit an Entity object.
protected  Table getTable()
          Returns the Table that can be used to display an Entity.
protected  void setViewerFactory(PajeFactory viewer)
          Sets the Viewer factory object.
 
Methods inherited from class org.pajes.db.entity.Viewer
build, getEntity, getScope, init, retrieve, 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

VIEWER_FACTORY

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

See Also:
Constant Field Values
Constructor Detail

DefaultViewer

public DefaultViewer()
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 Viewer has been defined, it will be requested to create a document.
  2. if noViewer has been defined, the ServletContext will be searched for an attribute named VIEWER_FACTORY, and the object returned by ServletContext.getAttribute will be requested to create a document. Context default Viewer 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 Table returned by getTable() will be added to the container.

The Entity used to populate the Paje 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.

getTable

protected Table getTable()
                  throws java.io.IOException
Returns the Table that can be used to display an Entity. All values will be displayed, except those where Attributes.getViewerPosition() 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 Table
Throws:
java.io.IOException - if an IO exception occurs.

setViewerFactory

protected void setViewerFactory(PajeFactory viewer)
Sets the Viewer factory object.

Parameters:
viewer - the Viewer factory object.

PAJES 2.3.9

Copyright © 2002-2003 Viridian Pty Limited. All Rights Reserved.