Inherits From:
NSObject
Conforms To: NSObject (NSObject)
Declared in: WebObjects/WOContext.h
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:inContext: , invokeActionForRequest:inContext: , and appendToResponse:inContext: 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.
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:
- (void)appendElementIDComponent: (NSString *)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
- (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:path:queryString:isSecure:port:
- (NSString *)completeURLWithRequestHandlerKey: (NSString *)requestHandlerKey
path: (NSString *)aRequestHandlerPath
queryString: (NSString *)aQueryString
isSecure: (BOOL)isSecure
port: (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 YES, this method uses "https" instead of "http." If somePort is 0 (zero), this method uses the default port.
See also: - urlWithRequestHandlerKey:path:queryString:
component
- (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
- (NSString *)componentActionURL
Returns the complete URL for the component action.
contextID
- (NSString *)contextID
Returns the context ID of the receiver.
deleteAllElementIDComponents
- (void)deleteAllElementIDComponents
Deletes all components of the current element ID.
See also: - appendElementIDComponent: , - appendZeroElementIDComponent , - incrementLastElementIDComponent
deleteLastElementIDComponent
- (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:queryDictionary:
- (NSString *)directActionURLForActionNamed: (NSString *)anActionName
queryDictionary: (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
- (NSString *)elementID
Returns the element ID identifying the current WOElement.This method helps you avoid creating a session in direct actions.
hasSession
- (BOOL)hasSession
Returns whether a session exists for the receiving context.
See also: - senderID
incrementLastElementIDComponent
- (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
Returns a WOContext instance initialized with a unique context ID. Generally, you should call initWithRequest: instead to ensure that the WOContext instance is properly initialized.
initWithRequest:
- (id)initWithRequest: (WORequest *)aRequest
Returns a WOContext with aRequest.
isInForm
- (BOOL)isInForm
Returns YES when in the context of a WOForm.
See also: setInForm:
Returns the WOComponent object that represents the request or response page.
See also: - component , - request , - response , - senderID
request
- (WORequest *)request
Returns the transaction's WORequest object.
See also: - component , - page , - response , - senderID
response
- (WOResponse *)response
Returns the transaction's WOResponse object.
See also: - component , - page , - response , - senderID
senderID
- (NSString *)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 nil
, as it always is on the first request of a session.
See also:
-
initWithRequest: ,
- request , -
uri (WORequest)
session
- (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:
- setInForm: (BOOL)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:path:queryString:
- (NSString *)urlWithRequestHandlerKey: (NSString *)requestHandlerKey
path: (NSString *)aRequestHandlerPath
queryString: (NSString *)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:path:queryString:isSecure:port: