Inherits From:
NSObject
Inherits From:
com.apple.yellow.webobjects
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
, invokeActionForRequest
, 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.
WOContext
()Returns a WOContext instance initialized with a unique context ID.
Class 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
(java.lang.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
completeURLWithRequestHandlerKey
public java.lang.String completeURLWithRequestHandlerKey
(java.lang.String requestHandlerKey,
java.lang.String aRequestHandlerPath,
java.lang.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
, senderID
componentActionURL
public java.lang.String componentActionURL
()
Returns the complete URL for the component action.
contextID
public java.lang.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 java.lang.String directActionURLForActionNamed
(java.lang.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 java.lang.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:
senderID
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
, senderID
request
public WORequest request
()
Returns the transaction's WORequest object.
See also:
component
, page
, response
, senderID
response
public WOResponse response
()
Returns the transaction's WOResponse object.
See also:
component
, page
, response
, senderID
senderID
public java.lang.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
urlWithRequestHandlerKey
public java.lang.String urlWithRequestHandlerKey
(java.lang.String requestHandlerKey,
java.lang.String aRequestHandlerPath,
java.lang.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 "?".
completeURLWithRequestHandlerKey