Documentation Archive Developer
Search
PATH Documentation > WebObjects

Table of Contents

WOContext


Inherits from:
Object
Implements:
Cloneable
Package:
com.webobjects.appserver


Class Description


A WOContext object lets you access objects and information that define the context of a transaction. In a typical request-response loop (a transaction), several objects have a hand in what is going on: the WOApplication and WOSession objects, the page involved in the request or response (a WOComponent object), the page's subcomponents (also WOComponents), plus the dynamic elements on the page. The WOContext object passed as an argument in the takeValuesFromRequest, invokeAction, and appendToResponse messages allows access to these objects. A context is identified by the context ID, which appears in the URL after the session ID and page name. Each context ID is an integer that the session increments each time a new context is created.

WOContext objects provide other information and services related to the current transaction. From them you can get the entire URL currently in effect as well as portions of that URL, such as the element ID, the context ID, and the URL up to and including the session ID.

A WOContext object plays a further role behind the scenes. For the benefit of a page's dynamic elements, it keeps track of the current component, that is, the WOComponent associated with the current element in the request-handling cycle. The current component can be the WOComponent that represents one of the page's subcomponents or the page itself. By reference to the current component (accessed through WOContext's component method), a dynamic element can exchange values associatively between itself and the WOComponent that contains it.




Method Types


Constructors
WOContext
Creating new object instances
contextWithRequest
Obtaining attributes
component
contextID
elementID
hasSession
isInForm
page
request
response
session
session
setInForm
Manipulating element ID
appendElementIDComponent
appendZeroElementIDComponent
deleteAllElementIDComponents
deleteLastElementIDComponent
incrementLastElementIDComponent
Generating URLs
directActionURLForActionNamed
completeURLWithRequestHandlerKey
componentActionURL
urlWithRequestHandlerKey


Constructors



WOContext

public WOContext(WORequest aRequest)

Returns a WOContext instance initialized with aRequest.


Static Methods



contextWithRequest

public static WOContext contextWithRequest(WORequest aRequest)

Creates and returns a WOContext with aRequest. This is the preferred way to create a WOContext. All other constructors call this one, so if you subclass WOContext, you need to override only this one.


Instance Methods



appendElementIDComponent

public void appendElementIDComponent(String aString)

Appends a string to the current element ID to create an identifier of an HTML element. For example, if the current element ID is "0.1.1" and you send this message with an argument of "NameField," the element ID for that field becomes "0.1.1.NameField".

See Also: deleteAllElementIDComponents, deleteLastElementIDComponent, incrementLastElementIDComponent



appendZeroElementIDComponent

public void appendZeroElementIDComponent()

Appends a ".0" to the current element ID to create an identifier of the first "child" HTML element. For example, if the current element ID is "0.1.1", after you send this message the element ID becomes "0.1.1.0".

See Also: deleteAllElementIDComponents, deleteLastElementIDComponent, incrementLastElementIDComponent



clone

public Object clone()

Conformance to Cloneable.

completeURLWithRequestHandlerKey

public String completeURLWithRequestHandlerKey( String requestHandlerKey, String aRequestHandlerPath, String aQueryString, boolean isSecure, int somePort)

Returns the complete URL for the specified request handler. The requestHandlerKey is one of the keys provided by WOApplication. The requestHandlerPath is any URL encoded string. The queryString is added at the end of the URL behind a "?". If isSecure is true, this method uses "https" instead of "http." If somePort is 0 (zero), this method uses the default port.

See Also: urlWithRequestHandlerKey



component

public WOComponent component()

Returns the component that dynamic elements are currently using to push and pull values associatively. This component could represent the current request or response page or a subcomponent of that page.

See Also: WOComponent class, page, request, response, session



componentActionURL

public String componentActionURL()

Returns the complete URL for the component action.

contextID

public String contextID()

Returns the context ID of the receiver.

deleteAllElementIDComponents

public void deleteAllElementIDComponents()

Deletes all components of the current element ID.

See Also: appendElementIDComponent, appendZeroElementIDComponent, incrementLastElementIDComponent



deleteLastElementIDComponent

public void deleteLastElementIDComponent()

Deletes the last digit (or name) of the current element ID, along with its dot separator. Thus, after sending this message, "0.0.1.1" becomes "0.0.1".

See Also: appendElementIDComponent, appendZeroElementIDComponent, incrementLastElementIDComponent



directActionURLForActionNamed

public String directActionURLForActionNamed( String anActionName, NSDictionary aQueryDict)

Returns the complete URL for the specified action. You can specify aQueryDict, and anActionName can be "ActionClass/ActionName" or "ActionName".

See Also: WODirectAction class specification



elementID

public String elementID()

Returns the element ID identifying the current WOElement.This method helps you avoid creating a session in direct actions.

hasSession

public boolean hasSession()

Returns whether a session exists for the receiving context.

See Also: session



incrementLastElementIDComponent

public void incrementLastElementIDComponent()

Increments the last digit of the current element ID. For example, after this message is sent, "0.0.1.2" becomes "0.0.1.3".

See Also: appendElementIDComponent, appendZeroElementIDComponent, deleteAllElementIDComponents, deleteLastElementIDComponent



isInForm

public boolean isInForm()

Returns true when in the context of a WOForm.

See Also: setInForm



page

public WOComponent page()

Returns the WOComponent object that represents the request or response page.

See Also: component, request, response, session



request

public WORequest request()

Returns the transaction's WORequest object.

See Also: component, page, response, session



response

public WOResponse response()

Returns the transaction's WOResponse object.

See Also: component, page, response, session



senderID

public String senderID()

Returns the part of the WORequest's URI that identifies the dynamic element on the page (such as a form or an active image) responsible for submitting the request. The sender ID is the same as the element ID used to identify the dynamic element. A request's sender ID may be null, as it always is on the first request of a session.

See Also: request , uri (WORequest)



session

public WOSession session()

Returns the object representing the receiving context's session, if one exists. If the receiver does not have a session, this method creates a new session object and returns it. Note that not all contexts have a session: Direct Actions, for instance, don't always need a session. Use hasSession to determine whether a context has a session associated with it.

See Also: component, page, request, response, WOSession class



setInForm

public void setInForm(boolean flag)

If you write something that behaves like a WOForm, set this to notify WODynamicElements that they are in a form.

See Also: isInForm



toString

public String toString()

Returns a String containing a string representation of the receiver.

urlWithRequestHandlerKey

public String urlWithRequestHandlerKey( String requestHandlerKey, String aRequestHandlerPath, String aQueryString)

Returns a URL relative to cgi-bin/WebObjects for the specified request handler. The requestHandlerKey is one of the keys provided by WOApplication. The requestHandlerPath is any URL encoded string. The queryString is added at the end of the URL behind a "?".

See Also: completeURLWithRequestHandlerKey



© 2001 Apple Computer, Inc. (Last Published April 15, 2001)


Table of Contents