Class wwProcess

Handling requests and serving as the developer's entry point for Web requests. Most of your Web interface coding will occur at this class level.

The wwProcess class is the heart of Web Connection from the developer's point of view. This class serves as your code entry point where custom logic occurs. Each request in your Web application maps to a method in a wwProcess subclass. To add new functionality you simply add a method to your implementation of the process class. The simplest implementation looks like this:

*************************************************************
DEFINE CLASS YourProcess AS WWC_PROCESS
*************************************************************

*********************************************************************
FUNCTION HelloWorld()
*********************

THIS.StandardPage("Hello World from the " + THIS.Class + "  process",;
                  "If you got here, everything should be working fine. The time is: " + TIME())
                  
ENDFUNC
* EOF HelloWorld

*********************************************************************
FUNCTION QuickData()
********************

IF !USED('tt_cust')
   USE (THIS.cAppStartPath + "tt_cust")
ENDIF

Response.HTMLHeader("Customer List")
Response.Write("Filename: " + DBF() )
Response.ShowCursor()
Response.HTMLFooter()

ENDFUNC

ENDDEFINE

which can be accessed with a URL like this:

Full Url Syntax

wc.wc?YourProcess~HelloWorld

Script Map syntax(where wc.dll is mapped to .YP)

HelloWorld.yp

Each additional method you add can be referenced in the same manner. Note that in the above StandardPage() is quick method that creates a fully self contained HTML page. For a more customized page you can use the wwResponse object (THIS.oResponse.Write() for example) to create programmatic output or expand template/script pages using the ExpandTemplate/ExpandScript methods of the wwResponse object.

The easiest way to create a new process class is to use the New Process Wizard from the Web Connection Management Console, which hooks up new process entries to the mainline and creates a skeleton class that you can simply start adding methods to.

Exposed generic objects

wwProcess exposes several objects as PRIVATE variables for easier reference:
  • Request
    This object is mapped to wwProcess::oRequest.

  • Response
    This object is mapped to wwProcess::oResponse

  • Server
    This object is mapped to wwProcess::oServer

  • Process
    The wwProcess object that is running the current request. In code this would be referenced as THIS, but in script and templates that value is not valid - use Process instead.

  • Session
    The wwSession object if you created one. This maps to wwProcess::oSession, and is only valid if you either call InitSession or manually create a session and assign it to this property. Otherwise the value is .NULL..

These objects are available everywhere in your applications since they sit at the top of the call stack when your code gets called. This means these objects are in scope in your request methods, as well as further down in your business objects. They are also in scope in in Script and Template files where you can do things like the following:

<%= Request.GetBrowser() %>

Class Members

MemberDescription

OnAuthenticated

OnAuthenticateUser

OnCheckForAuthentication

Checks to see if a user is logged in when running in UserSecurity authentication mode.

Use this method if you just want to check if a user is logged in, without forcing them to actually login. This method sets the cAuthenticatedUser and cAuthenticatedUserName property.

OnError

Occurs when an error occurs in the Web Connection Process handling and Server.lDebugMode is set to .T.

OnLogout

OnProcessComplete

This event is fired after the request processing has completed, but before the Process object is disposed and the response is sent back to the client.

OnProcessInit

The OnProcessInit method is a hook that can be used to initialize a process class. Here you can create custom objects, run additional configuration tasks that apply to every request that hits this process class.

OnShowAuthenticationForm

OnUrlRewrite

AddAntiForgeryToken

o.AddAntiForgeryToken(llAsHtml)

Authenticate

o.Authenticate(lcUserName,lcErrorMessage,llNoForcedLogin)

CaptchaImage

Dual purpose function that is used to set a CAPTCHA image and then also serve the image to the client. CAPTCHA can be used to validate a request and ensure that a user enters the data as opposed to a robot or HTTP client to minimize SPAMming any form entries.

o.CaptchaImage(lcText,lcFont,lnFontSize)

CheckAntiForgeryToken

Used to check an AntiForgeryToken injected into the page via AddAntiForgeryToken().

Used to prevent Cross-site scripting attacks by preventing remote domain submission using a local only cookie. For more information please the documentation for AddAntiForgeryToken

o.CheckAntiForgeryToken(lnTimeoutSeconds)

ErrorMsg

o.ErrorMsg(lcHeader, lcBody, lvHeader, lnRefresh, lcRefreshUrl, lcIcon)

GetAppSetting

Returns a setting from the application's INI file.

o.GetAppSetting(lcKey,lcSection)

GetUrlBasePath

Retrieves the virtual path of the current request. The value is provided with leading and trailing forward slashes. This path is used to resolve paths for ResolveUrl().

o.GetUrlBasePath()

GetWCIniSetting

This method can be used to read values from the wc.ini file.

o.GetWCIniSetting(lcKey,lcSection)

GetWebResourceUrl

Returns a URL to retrieve a Web Resource that is embedded in the application or served by the application dynamically. The URL can be used to embed the resource into the page.

o.GetWebResourceUrl(lcResourceKey)

InitSession

o.InitSession(lcSessionCookieName, lnTimeoutSeconds, llPersist, llSecure)

LogError

Method that is used to log an error into the Web Connection Error Log. This method should be called from the OnError event of this class.

o.LogError(loException)

PageFooterTemplate

Renders a default footer template that is found in Views\_PageFooterTemplate.html.

o.PageFooterTemplate(lcTemplatePath)

PageHeaderTemplate

Renders a standard page header based on the default header template located in Views\_PageHeaderTemplate.html.

o.PageHeaderTemplate(lcTitle, lcTemplatePath)

PageTemplate

Renders a complete page template into which you can embed HTML template. It uses the template stored at Views\_PageTemplate.html to render the default template and you can customize this template

o.PageTemplate(lcTitle,lcContent,lcTemplatePath)

Process

Use of this method is deprecated. You should use OnProcessInit instead.

o.Process()

ReleaseSession

Releases the specified session by removing expiring and clearing the session cookie and deleting the session record.

o.ReleaseSession(lcSessionId)

ResolvePath

### Version 6.50
*not released yet*

o.ResolvePath(lcPath)

ResolveServerUrl

o.ResolveServerUrl(lcVirtualUrl, lcPrefix)

ResolveUrl

o.ResolveUrl()

SendAdminEmail

o.SendAdminEmail(lcTitle,lcMessage, lcRecipients,lcSender, llHtml,llAsync, @lcRefErrorMessage)

SendErrorEmail

This method sends email to the assigned administrator. It's specialized in that the email message automatically contains status information about the currently running Web request to help pin down the problem easier.

o.SendErrorEmail(lcSubject, lcMessage, lcRecipient, lcSender)

StandardPage

This method is identical in behavior to the ErrorMsg() method and the default implementation simply calls back to the ErrorMsg() method. Please see the documentation for this method. The main reason for both methods is to provide one error message and one status message page separately.

o.StandardPage(lcHeader, lcBody, lvHeader, lnRefresh, lcRefreshUrl,lcIcon)

WebResource

Generic output method can be used to serve embedded resources like related image, css, javascript or other files through the application

o.WebResource()

cAuthenticatedName

When authenticated holds the users display name.

cAuthenticatedUser

The authenticated user id after the user has been authenticated by either a success call to Authenticate() or OnCheckForAuthentication().

cAuthenticationMode

The method used to authenticate requests. Supported methods: Basic, UserSecurity, Custom

cAuthenticationUserMessage

Message displayed on the Authentication dialog for the user when cAuthenticationMode is UserSecurity.

cAuthenticationUserSecurityClass

The class used for Authentication when the cAuthenticationMode is set to UserSecurity.

cAuthenticationUserSecurityKey

The session key that is used to hold the UserSecurity authentication value.

cErrorTemplate

This method allows overriding the default error display page using a template page called through ExpandTemplate. If set specifies a full physical disk path to a page that is used for ErrorMsg and StandardPage output.

cMethodExecutionExclusions

Allows exluding of class methods that are executed as methods on the process class. This allows executing of script pages even if a matching method exists on the wwProcess subclass.

cSessionKey

The name of the Session Cookie used for this application. This is the default Session value.

cUrlBasePath

The Web Application Virtual Path that marks the base path of this application. This path is used internally by ResolveUrl() to define the base path for a URL and the resolving of the ~ character in a path.

lEnableSessionState

Turns on Session Handling for this request.

lIsAuthenticated

Determines if the current user has been authenticated after a call to Authenticate() or OnCheckForAuthentication().

Determines if the current request has been successfully authenticated and all user variables are available. This property checks if cAuthenticatedUser is .T.

lShowRequestData

Flag that when set causes the current request data - Form Variables, ServerVariables, Session Vars - to be displayed at the end of the current request.

nAuthenticationTimeoutMinutes

nPageScriptMode

Determines the script mode used when a matching method is not found in the class.

  1. Template (ExpandTemplate())
  2. Web Control Framework Page
  3. Script (ExpandScript())

The default value is 1.

oConfig

The oConfig member maps to the server's configuration object for this project.

oRequest

Object reference to a ready to use wwRequest object, which is used for all inputs of your application. This object is preset by the Init method of this class. When Process or your custom methods get control the oRequest object is already set.

oResponse

Object reference to a ready to use wwResponse object, which is used for all HTTP output. This object is preset by the Init method of this class. When Process or your custom methods get control the oResponse object is already set.

oServer

Object reference to a ready to use wwServer object, which is passed down from the wwServer Process method which calls into your wwProcess subclass. This object is preset by the Init method of this class. When Process or your custom methods get control the oServer object is already set.

oSession

If you use the InitSession() method the oSession object will be loaded for you during the call to that method. Once loaded you can access the oSession object to retrieve and store session variables.

oUser

If a request Authenticated using cAuthenticationMode of UserSecurity you can access the User Security's

FUNCTION OnLoad()

IF !Process.Authenticate()
   RETURN
ENDIF

this.lblMessage.Text = this.cAuthenticatedUser + " " + ;
                this.oUserSecurity.oUser.Fullname)
ENDFUNC

oUserSecurity

Requirements

Assembly: wwProcess.prg

See also:

Class wwProcess | New Process Wizard

© West Wind Technologies, 1996-2019 • Updated: 01/01/16
Comment or report problem with topic