The Wizard also allows you to configure a scriptmap that maps to this sub-application. This allows for script based request routing where the extension (.wpfor WebProcess) is always routed to the new class and the page name (Helloworld.wp goes to WebProcess::HelloWorld). The default wwProcess handler makes this type of request routing automatic.
DO CASE
CASE lcParameter == "WEBPROCESS"
DO WebProcess with THIS
*** SUB APPLETS ADDED ABOVE - DO NOT MOVE THIS LINE ***
CASE lcParameter == "WWMAINT"
DO wwMaint with THIS
OTHERWISE
*** Check for Script Mapped files for: .WC, .WCS, .FXP
lcPhysicalPath=THIS.oRequest.GetPhysicalPath()
lcExtension = Upper(JustExt(lcPhysicalPath))
DO CASE
CASE lcExtension == "WP"
DO WebProcess with THIS
*** ADD SCRIPTMAP EXTENSIONS ABOVE - DO NOT MOVE THIS LINE ***
*** Default Web Connection handling
CASE lcExtension == "WC" OR lcExtension == "FXP"
DO wwScriptMaps with THIS
...
ENDCASE
...
ENDCASE
Once these comments are in the document, the wizard will insert routing code above those lines for the plain parameters (wc.dll?webDemo~HelloWorld) as well as script mapped parsing (HelloWorld.wp).
Note you should also add any SET PROCEDURE,CLASSLIB, PATH and other commands that you expect to require in your custom code to the SetServerProperties method.
The process class generated looks as follows:
************************************************************************
*PROCEDURE WebProcess
****************************
LPARAMETER loServer
LOCAL loProcess
#INCLUDE WCONNECT.H
loProcess=CREATE("WebProcess",loServer)
IF VARTYPE(loProcess)#"O"
*** All we can do is return...
WAIT WINDOW NOWAIT "Unable to create Process object..."
RETURN .F.
ENDIF
*** Call the Process Method that handles the request
loProcess.Process()
RETURN
*************************************************************
DEFINE CLASS WebProcess AS WWC_PROCESS
*************************************************************
*********************************************************************
* Function WebProcess :: Process
************************************
*** If you need to hook up generic functionality that occurs on
*** every hit, implement this method then call DoDefault() to
*** get the default Request Processing functionality. See docs
*** for more info on how to customize wwProcess::Process behavior.
*********************************************************************
*!* FUNCTION Process
*!*
*!* THIS.InitSession("wwDemo")
*!*
*!* IF !THIS.Login("any")
*!* RETURN .F.
*!* ENDIF
*!*
*!* DODEFAULT()
*!*
*!* RETURN .T.
*!* ENDFUNC
*********************************************************************
FUNCTION HelloWorld()
************************
THIS.StandardPage("Hello World from the WebProcess process",;
"If you got here, everything should be working fine")
ENDFUNC
* EOF WebProcess::HelloWorld
*** Recommend you override the following methods:
*** ErrorMsg
*** StandardPage
*** Error
ENDDEFINEWhen you generate this process class you should be able to immediately access it with either:
Looking at the code you can see that the Process method is generated but commented out. By default the wwProcess's Process method is used to handle all request processing. You should uncomment the custom process code if you need to provide any generic handling that needs to occur on every hit as the Process method is called before any other method in the class fires from a Web hit. This method is perfect for handling things like authentication, cookie checks and assignment, logging etc. Make sure that if you implement this method you add a call to DoDefault to call the default behavior, which is responsible for routing the request to the appropriate method of the class (like HelloWorld).