org.histpop.ohpr.frames
Class ViewFrame

java.lang.Object
  extended by org.histpop.ohpr.frames.ViewFrame
All Implemented Interfaces:
BasicFrame
Direct Known Subclasses:
AssociatedViewFrame, ViewFrame2

public class ViewFrame
extends java.lang.Object
implements BasicFrame

A frame class for generating a view of a target document for an Essay or Legislation. The view is created from a HTML template. The template contains some placeholders which are replaced by dynamically generated HTML-code for the final output.


Constructor Summary
ViewFrame()
           
 
Method Summary
protected  java.lang.String createURL(java.lang.String frame, TitleQueryNode titleNode, ServerContext ctx)
          Generate an URL for a given target frame for single page documents.
 HTMLHandler display(java.lang.Object result, ServerContext ctx)
          Create an HTML view for browsing requests.
protected  java.lang.String generateAssociatedContentLink(java.lang.String frame, TitleQueryNode titleNode, ServerContext ctx)
          Generate the Associated Content link.
protected  java.lang.String generateContent(PageQueryState pagesState)
          Retrieve the document content and replace some placeholders in the document with the actual links.
protected  java.lang.String replaceLink(java.lang.String linkMarker, MasterNumber originTitle, Page originPage)
          Replace a linkMarker with a HTML link to an associated target page or an associated document.
protected  java.lang.String replaceLinks(java.lang.String content, MasterNumber originTitle, Page originPage)
          Replace all link markers with HTML links pointing to associated target pages or associated documents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewFrame

public ViewFrame()
Method Detail

createURL

protected java.lang.String createURL(java.lang.String frame,
                                     TitleQueryNode titleNode,
                                     ServerContext ctx)
Generate an URL for a given target frame for single page documents.

Parameters:
frame - The name of a target frame which generates a dynamic HTML view.
titleNode - A master item of a Legislation or Essay document.
ctx - The server context containing the request, response, and current session objects.
Returns:
An escaped URL string.

generateAssociatedContentLink

protected java.lang.String generateAssociatedContentLink(java.lang.String frame,
                                                         TitleQueryNode titleNode,
                                                         ServerContext ctx)
Generate the Associated Content link.

Parameters:
frame - The name of a target frame which generates a dynamic HTML view.
titleNode - A master item of a Legislation or Essay document.
ctx - The server context containing the request, response, and current session objects.
Returns:
A link to the Associated Content page.

replaceLink

protected java.lang.String replaceLink(java.lang.String linkMarker,
                                       MasterNumber originTitle,
                                       Page originPage)
                                throws ServerException
Replace a linkMarker with a HTML link to an associated target page or an associated document.

Parameters:
linkMarker - A link marker in one of the following formats:
[MN master-number] or
[MN master-number.chunk.pageno]
originTitle - The peristent object of the current master number item.
originPage - The peristent object of the current page.
Returns:
The HTML link to the associated target.
Throws:
ServerException

replaceLinks

protected java.lang.String replaceLinks(java.lang.String content,
                                        MasterNumber originTitle,
                                        Page originPage)
                                 throws ServerException
Replace all link markers with HTML links pointing to associated target pages or associated documents.

Parameters:
content - The original document content with link markers.
originTitle - The peristent object of the current master number item.
originPage - The peristent object of the current page.
Returns:
The same content, with all link markers replaced by actual HTML links.
Throws:
ServerException

generateContent

protected java.lang.String generateContent(PageQueryState pagesState)
                                    throws ServerException
Retrieve the document content and replace some placeholders in the document with the actual links.

Parameters:
pagesState - A session cache with all the page of the master number item.
Returns:
The document content.
Throws:
ServerException

display

public HTMLHandler display(java.lang.Object result,
                           ServerContext ctx)
                    throws java.lang.Exception
Create an HTML view for browsing requests. It uses an HTML template with placeholders which are replaced by dynamcially generated HTML. The following URL arguments are expected after the '?' character:
path=path to tree node


treestate=contract or expand or expandnew
(Only used if not a leaf-node)

active=yes or no

titlepos=position of first title to be displayed
(default is zero, not needed here, but used when returning to the browse list)

mno=master number of volume or document

Specified by:
display in interface BasicFrame
Parameters:
result - The result from a server method, always NULL, unless exception thrown.
ctx - The server context containing the request, response, and current session objects.
Returns:
An HTML handler containing the generated HTML ready to be sent back as a response by the servlet controller.
Throws:
java.lang.Exception