Generated Code
Skeleton for hand crafted manipulation class
package PrototypePackageName;
import java.util.*;
// import java.net.URLEncoder;
import org.w3c.dom.*;
import org.w3c.dom.html.*;
import com.lutris.util.*;
import com.lutris.xml.xmlc.*;
import com.lutris.appserver.server.ApplicationException;
import com.lutris.appserver.server.sql.*;
import com.lutris.appserver.server.httpPresentation.*;
import com.lutris.appserver.server.session.*;
import com.pisoftware.platypus.production.*;
import PrototypeAppName.presentation.*;
import PrototypePackageName.*;
import PrototypeAppName.business.*;
import PrototypeBusinessPackageName.*;
import PrototypeAppName.data.*;
import PrototypeAppName.util.*;
/**
* Class PrototypePOName manipulates the DOM
* model created by class PrototypePOName.
*
* TO DO: More detailed doco on what this class does.
*
* Generated by Platypus version PROTOTYPE VersionLocn.
**/
public class PrototypePOName extends PrototypePONameBASE{
////// Miscellaneous variables for presentation object
// Query string and database variables are in a lower section.
/** URL to which we will redirect the browser, after this class does its work. **/
String redirectURL ;
////// Variables for the query string values
PrototypeHandCGIDecls
////// Variables for database query.
// End of database field declarations section.
/**
* Does the actual manipulation of the DOM data structure.
*
* It defines the abstract method in PrototypePONameBASE.java.
*
* @exception ApplicationException
* @exception HttpPresentationException
**/
public void manipulate() throws ApplicationException, HttpPresentationException {
////// Initialise
bo = new PrototypePONameBO( comms ); // Do not delete. May do user authentification, etc.
//// Set DEBUG flag
DEBUG = false ;
if( ProdUtil.nameInQueryString( args, "DEBUG" ) ) DEBUG = true ;
if( ProdUtil.sessionDebugFlag( debugData ) ) DEBUG = true ;
////// Get values from query string
PrototypeHandCGIInits
// DBG
PrototypeHandCGIInitDBG
////// Fill dynamic nodes
////// Restoring FORMS, if necessary
if( ProdUtil.nameInQueryString( args, "RESTOREQUERYSTRING" ) ){
ProdUtil.restoreFormsFromPresentationData( document, presentationData );
}
////// Generate debugging information, if requested.
if( DEBUG ){
HTMLElement debugTemplate ;
//// Fill in debugging information
debugTemplate = startDebugTemplate(); // Method is in BASE class.
//// Insert debugging information into DOM tree.
HTMLBodyElement bodyElement = ProdUtil.getBodyElement( document );
bodyElement.insertBefore( debugTemplate, null );
}
////// Redirect to confirmation page.
redirectURL = "PROTOTYPE PORedirectAlwaysURL" ; // TODO: Check redirectURL. Should include path from presentation/.
throw new ClientPageRedirectException( comms.request.getAppFileURIPath( redirectURL ) );
}
}
Base manipulation class
package PrototypePackageName;
import java.util.*;
import org.w3c.dom.*;
import org.w3c.dom.html.*;
import com.lutris.util.*;
import com.lutris.xml.xmlc.*;
import com.lutris.appserver.server.ApplicationException;
import com.lutris.appserver.server.httpPresentation.*;
import com.lutris.appserver.server.session.*;
import com.pisoftware.platypus.production.*;
import PrototypeAppName.util.*;
import PrototypeAppName.data.*;
import PrototypeAppName.business.*;
import PrototypeBusinessPackageName.*;
import PrototypeAppName.presentation.*;
import PrototypePackageName.*;
/**
* Class PrototypePONameBASE provides
* lots of methods and variables useful for manipulating the DOM data
* structure created by class PrototypePONameHTML.
*
* Generated by Platypus version PROTOTYPE VersionLocn.
**/
public abstract class PrototypePONameBASE implements HttpPresentation {
////// Variable declarations
/** Business object which supports this presentation object **/
PrototypePONameBO bo = null ;
/** Enhydra's DOM model for PO we're generating code for **/
PrototypePONameHTML po ;
/** DOM Document at root of presentation DOM data structure **/
Document document ;
/** HttpPresentationComms object passed to run() **/
HttpPresentationComms comms ;
/** Session data **/
SessionData sessionData ;
/** Section of session data reserved for presentation layer **/
KeywordValueTable presentationData ;
/** Section of session data reserved for debug flags. **/
KeywordValueTable debugData ;
/** Name value pairs from query string **/
KeywordValueTable args ;
/** Unique id number for this invocation of the page. **/
String servedId ;
/** Debugging flag **/
boolean DEBUG ;
Prototype BaseDecls
/**
* Does the actual manipulation of the DOM data structure.
*
* It is instantiated in the hand-crafted manipulation
* class PrototypePONameBASE.java.
*
* @exception ApplicationException
* @exception HttpPresentationException
**/
public abstract void manipulate() throws ApplicationException, HttpPresentationException ;
/**
* @exception HttpPresentationException
**/
// Uses variables like 'comms' and 'sessionData', so is in BASE class. Otherwise,
// would belong in the ProdUtil class. One day, when stable, move to ProdUtil.
HTMLElement startDebugTemplate() throws HttpPresentationException {
AppTemplateHTML appTemplateHTML = new AppTemplateHTML();
appTemplateHTML.setTextDebugQueryString( HttpUtil.getQueryFromRequest( comms.request ) );
appTemplateHTML.setTextDebugSessionData( sessionData.toString() );
return (HTMLElement) appTemplateHTML.getElementDebugTemplate();
}
/**
* @exception HttpPresentationException
**/
public void run( HttpPresentationComms comms ) throws HttpPresentationException {
////// Initialise
this.comms = comms ;
sessionData = comms.sessionData ;
presentationData = ProdUtil.presentationData( sessionData );
debugData = ProdUtil.ensureSectionData( "DEBUG", presentationData );
po = new PrototypePONameHTML();
document = po.getDocument();
servedId = ProdUtil.getUniquePageString( presentationData );
////// Process query string
try{
args = HttpUtil.buildQueryTable( HttpUtil.getQueryFromRequest( comms.request ) );
}catch( KeywordValueException kve ){
throw new HttpPresentationException( "Couldn't get CGI query string", kve );
}
////// Initialise prototype variables
Prototype BaseInits
////// Let the hand-crafted code manipulate the DOM data structure
try{
manipulate();
}catch( UserException ue ){
PROTOTYPE AppTemplate.processUserException( document, ue );
}catch( ApplicationException ae ){
throw new HttpPresentationException( ae );
}
////// Do we have any admin messages for user?
try{
if( null == bo ) bo = new PrototypePONameBO( comms );
PROTOTYPE AppTemplate.perhapsGenerateAdminNotification( bo.getBusinessIdValue( "AdminNotice" ), document, sessionData );
}catch( ApplicationException ae ){
// We've almost got the page -- lets serve it, but put a message in the logs
ProdUtil.log( "Failed to get admin message in PrototypePOName: " );
ProdUtil.log( "\t" + ae.getMessage() );
}
////// Remove ID attributes from nodes
ProdUtil.removeIDAttributes( document );
////// Write out manipulated DOM as HTML
comms.response.writeHTML(po.toDocument());
}
}
Code Scrap Book
This code is used by the code generator.
////// Declarations for DB query for PrototypeAccessName
/** Count of records returned by PrototypeAccessName DB query. **/
int countPrototypeAccessName ;
/** Loop index **/
int iPrototypeAccessName ;
/** Clone of prototype node, after prototype is filled with data. **/
Node newPrototypeAccessName ;
// /** List of ID nodes in a cloned access tree. **/
// Hashtable idnodesPrototypeAccessName ;
////// Processing records from DB query for ID PrototypeAccessName
countPrototypeAccessName = bo.getPrototypeAccessName( PrototypeAccessArgList );
if( countPrototypeAccessName > 0 ){
// DBG
ProdUtil.debug( "Query on PrototypeAccessName returned " + countPrototypeAccessName + " records." );
for( iPrototypeAccessName=0 ; iPrototypeAccessName<countPrototypeAccessName ; iPrototypeAccessName++ ){
//////// Get field values from a PrototypeAccessName record
// DBG
ProdUtil.debug( "Filled access PrototypeAccessName record #" + iPrototypeAccessName );
////// Hey! If there was only one record, go straight to the next page of the workflow
// Note: this section is usually used on LIST pages.
if( 1 == countPrototypeAccessName ){
////// Exactly one record found. Go to next page in workflow.
// NOTE: ClientPageRedirect assumes absolute pathnames, *not* relative.
String tmpQueryString = "" ;
// TODO: tmpURLString should contain drill down URL.
redirectURL = ProdUtil.URLAppAbsoluteDir( PrototypePORedirectListURL, "PrototypePODirectory" ) ;
throw new ClientPageRedirectException( comms.request.getAppFileURIPath(redirectURL));
}
////// Set up alternating CLASS attributes.
// NOTE: Mostly used for table rows when each is a DB record.
ProdUtil.setClassAttributeModulo( protoPrototypeIdName, iPrototypeAccessName );
////// Clone DOM node for PrototypeAccessName record, and insert it.
newPrototypeAccessName = protoPrototypeIdName.cloneNode( true );
// idnodesPrototypeAccessName = ProdUtil.idHashtable( (HTMLElement) newPrototypeAccessName );
ProdUtil.insertSiblingBefore( newPrototypeAccessName, protoPrototypeIdName );
}
}else{
// There were no PrototypeAccessName records returned from DB
// TODO: Check value for PO with query form (2nd arg below), eg "reports/SalesDate"
throw new UserException( "No records were found matching your request.", "PROTOTYPE POAccessFromPO" );
}
////// Remove prototype from DOM
ProdUtil.removeThisNode( protoPrototypeIdName );