| 
 | WebObjects 5.2.3 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.webobjects.appserver.WOContext
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 methods allows access to these objects. A context is
 identified by the contextID, which appears in the URL after the
 session ID and page name. Each contextID 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.
component(), 
WOComponent.takeValuesFromRequest(WORequest aRequest, WOContext aContext), 
WOComponent.invokeAction(WORequest aRequest, WOContext aContext), 
WOComponent.appendToResponse(WOResponse aResponse, WOContext aContext)| Nested Class Summary | 
| Nested classes inherited from class com.webobjects.foundation.NSKeyValueCoding | 
| NSKeyValueCoding.DefaultImplementation, NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.Null, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.Utility, NSKeyValueCoding.ValueAccessor | 
| Nested classes inherited from class com.webobjects.foundation.NSKeyValueCodingAdditions | 
| NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility | 
| Field Summary | 
| Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding | 
| NullValue | 
| Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions | 
| KeyPathSeparator | 
| Constructor Summary | |
| WOContext(WORequest aRequest)Returns a WOContext instance initialized with aRequest. | |
| Method Summary | |
|  void | appendElementIDComponent(String aString)Appends a string to the current element ID to create an identifier of an HTML element. | 
|  void | appendZeroElementIDComponent()Appends a ".0" to the current element ID to create an identifier of the first "child" HTML element. | 
| static boolean | canAccessFieldsDirectly()WOContext's implementation of this static method returns true, indicating that key/value coding is allowed to access fields in this object if an appropriate method isn't present. | 
|  Object | clone() | 
|  String | completeURLWithRequestHandlerKey(String requestHandlerKey,
                                 String aRequestHandlerPath,
                                 String aQueryString,
                                 boolean isSecure,
                                 int somePort)Returns the complete URL for the specified request handler. | 
|  WOComponent | component()Returns the WOComponent that dynamic elements are currently using to push and pull values associatively. | 
|  String | componentActionURL()Returns a URL for a component action relative to cgi-bin/WebObjects. | 
|  String | contextID()Returns the context ID of the receiver. | 
| static WOContext | contextWithRequest(WORequest aRequest)Deprecated. use WOContext(WORequest aRequest) instead | 
|  void | deleteAllElementIDComponents()Deletes all components of the current element ID. | 
|  void | deleteLastElementIDComponent()Deletes the last digit --or name-- of the current element ID, along with its dot separator. | 
|  String | directActionURLForActionNamed(String anActionName,
                              NSDictionary aQueryDict)Returns a complete URL for the specified action. | 
|  String | elementID()Returns an element ID. | 
|  Object | handleQueryWithUnboundKey(String key)Invoked from valueForKeywhen it finds no property binding
 forkey. | 
|  void | handleTakeValueForUnboundKey(Object value,
                             String key)Invoked from takeValueForKeywhen it finds no property binding
 forkey. | 
|  boolean | hasSession()Returns trueif a session exists for the receiving context,falseotherwise. | 
|  void | incrementLastElementIDComponent()Increments the last digit of the current element ID. | 
|  boolean | isInForm()Used by subclasses of WODynamicElement to determine if the context is in a WOForm element. | 
|  WOComponent | page()Returns a WOComponent object that represents either the request or response page. | 
|  WORequest | request()Return the context's WORequest object. | 
|  WOResponse | response()Return the context's WOResponse object. | 
|  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. | 
|  WOSession | session()Returns the object representing the receiving context's session, if one exists. | 
|  void | setInForm(boolean aFlag)If you write something that behaves like a WOForm, invoke this method with aFlagtrueinappendToResponse(WOResponse aResponse, WOContext aContext)before callingsuper.appendToResponse(WOResponse aResponse, WOContext aContext)to notify any contained WODynamicElements that they are in a form. | 
|  void | takeValueForKey(Object value,
                String key)Sets the value for the property identified by keytovalue. | 
|  void | takeValueForKeyPath(Object value,
                    String keyPath)Sets the value for the property identified by keyPathtovalue. | 
|  String | toString() | 
|  void | unableToSetNullForKey(String key)Invoked from takeValueForKeywhen it is given anullvalue
 for a scalar property (such as anintor afloat). | 
|  String | urlWithRequestHandlerKey(String requestHandlerKey,
                         String aRequestHandlerPath,
                         String aQueryString)Returns a URL relative to cgi-bin/WebObjectsfor the specified
 request handler. | 
|  Object | valueForKey(String key)Retrieves the value of the property named by key. | 
|  Object | valueForKeyPath(String keyPath)Retrieves the value of a property of the object at the end of the key path (a key path is a string of the form "key1.key2"). | 
| Methods inherited from class java.lang.Object | 
| equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Constructor Detail | 
public WOContext(WORequest aRequest)
aRequest.
aRequest - request that initializes the instance| Method Detail | 
public void appendElementIDComponent(String aString)
aString - String to be appended to the current element IDappendZeroElementIDComponent(), 
deleteAllElementIDComponents(), 
deleteLastElementIDComponent(), 
incrementLastElementIDComponent()public void appendZeroElementIDComponent()
appendElementIDComponent(String aString), 
deleteAllElementIDComponents(), 
deleteLastElementIDComponent(), 
incrementLastElementIDComponent()public static boolean canAccessFieldsDirectly()
truepublic Object clone()
public String completeURLWithRequestHandlerKey(String requestHandlerKey,
                                               String aRequestHandlerPath,
                                               String aQueryString,
                                               boolean isSecure,
                                               int somePort)
requestHandlerKey is one of the keys registered with WOApplication.
 The requestHandlerPath is any URL encoded string. The
 aQueryString 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.
requestHandlerKey - one of the keys registered with WOApplicationaRequestHandlerPath - any URL encoded stringaQueryString - added at the end of the URLisSecure - if true the method uses "https" instead of "http"somePort - the port on which the request handler is listening if 0 this method uses the default port request handler
urlWithRequestHandlerKey(String requestHandlerKey, String aRequestHandlerPath, String aQueryString), 
WOApplication.registeredRequestHandlerKeys()public WOComponent component()
takeValuesFromRequestinvokeAction phases of request handling, this
 will be either the current request, or a subcomponent of that page. During the appendToResponse
 phase, it will return the response page or a subcomponent.
page(), 
request(), 
response(), 
session(), 
WOComponentpublic String componentActionURL()
cgi-bin/WebObjects.
 The exact form of the URL will vary depending on whether the application is caching
 pages and whether the session ID is being stored in the URL or not.
public String contextID()
public static WOContext contextWithRequest(WORequest aRequest)
aRequest - WORequest
aRequestpublic void deleteAllElementIDComponents()
appendElementIDComponent(String aString), 
appendZeroElementIDComponent(), 
deleteLastElementIDComponent(), 
incrementLastElementIDComponent()public void deleteLastElementIDComponent()
appendElementIDComponent(String aString), 
appendZeroElementIDComponent(), 
deleteAllElementIDComponents(), 
incrementLastElementIDComponent()
public String directActionURLForActionNamed(String anActionName,
                                            NSDictionary aQueryDict)
anActionName can be either an
 action -- "ActionName" -- or an action on a class -- "ActionClass/ActionName". You can also
 specify aQueryDict to be an NSDictionary which contains form values as
 key/value pairs.
anActionName - String action nameaQueryDict - NSDictionary containing query key/value pairs
WODirectActionpublic String elementID()
element ID. This element ID is used by WOElements during the appendToResponse
 phase of request handling to create URLs, and during the invokeAction phase to determine which element
 was activated. This element ID will change as appendElementIDComponent etc are invoked.
element ID identifying the current WOElementappendElementIDComponent(String aString), 
appendZeroElementIDComponent(), 
deleteAllElementIDComponents(), 
deleteLastElementIDComponent(), 
incrementLastElementIDComponent()public Object handleQueryWithUnboundKey(String key)
NSKeyValueCoding.ErrorHandlingvalueForKey when it finds no property binding
 for key. The default implementation
 throws an NSKeyValueCoding.UnknownKeyException,
 with the target object(TargetObjectUserInfoKey) and 
 key(UnknownUserInfokey)
 in the user info. An NSKeyValueCoding.ErrorHandling class can override this
 method to handle the query in some other way. The method can return a value,
 in which case that value is returned by the corresponding
 valueForKey invocation.
handleQueryWithUnboundKey in interface NSKeyValueCoding.ErrorHandlingkey - the property name which generated this error
null that the custom implementation desires.  The default implementation throws an exception instead.NSKeyValueCoding.valueForKey(java.lang.String), 
NSKeyValueCoding.UnknownKeyException, 
NSKeyValueCoding.DefaultImplementation
public void handleTakeValueForUnboundKey(Object value,
                                         String key)
NSKeyValueCoding.ErrorHandlingtakeValueForKey when it finds no property binding
 for key. The default implementation
 throws an NSKeyValueCoding.UnknownKeyException, with the
 target object(TargetObjectUserInfoKey) and key(UnknownUserInfoKey)
 in the user info dictionary of the exception.  An NSKeyValueCoding.ErrorHandling class can override this
 method to handle the error in some other way.
handleTakeValueForUnboundKey in interface NSKeyValueCoding.ErrorHandlingvalue - the new value which could not be setkey - the name of the property which generated this errorNSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String), 
NSKeyValueCoding.UnknownKeyException, 
NSKeyValueCoding.DefaultImplementationpublic boolean hasSession()
true if a session exists for the receiving context, false otherwise.
true if a session exists for the receiving context, false otherwisesession()public void incrementLastElementIDComponent()
appendElementIDComponent(String aString), 
appendZeroElementIDComponent(), 
deleteAllElementIDComponents(), 
deleteLastElementIDComponent()public boolean isInForm()
true when in the context of a WOForm, false otherwisesetInForm(boolean flag)public WOComponent page()
takeValuesFromRequestinvokeAction
 phases of request handling, it will return the request page. If it is called during
 appendToResponse phase, it will return the response page. During the first two
 phases, the request page is determined by the context ID in the request -- if one exists,
 and is restored from the user's session's page cache.
component(), 
request(), 
response(), 
session(), 
WOSession.restorePageForContextID(String aContextID)public WORequest request()
component(), 
page(), 
response(), 
session()public WOResponse response()
component(), 
page(), 
response(), 
session()public String senderID()
null, as it always is on the first request of a
 session.
request(), 
WORequest.uri()public WOSession session()
hasSession to determine whether a context
 has a session associated with it.
 In the case of a direct action, if a session could not be restored from a session ID
 this method attempts to create a new session by calling WOApplication.createSessionForRequest(WORequest request).
 If createSessionForRequest(WORequest request) returns null, this method throws an
 IllegalStateException (catch it in your direct action to manually handle session creation error).
component(), 
page(), 
request(), 
response(), 
hasSession(), 
WOSession, 
WOApplication.createSessionForRequest(WORequest request)public void setInForm(boolean aFlag)
aFlag 
 true in appendToResponse(WOResponse aResponse, WOContext aContext)
 before calling super.appendToResponse(WOResponse aResponse, WOContext aContext)
 to notify any contained WODynamicElements that they are in a form.
 After super.appendToResponse(WOResponse aResponse, WOContext aContext) is done,
 revert the change by invoking invoke this method with aFlag false.
aFlag - truenotifies WODynamicElements that they are in a formisInForm()
public void takeValueForKey(Object value,
                            String key)
NSKeyValueCodingkey to value.The default implementation provided by NSKeyValueCoding.DefaultImplementation works as follows:
setKey, and invokes it if there is one._setKey,
 and invokes it if there is one.canAccessFieldsDirectly returns true, searches for a
 field based on key and sets its value directly.
 For the key "lastName", this would be _lastName, _isLastName, lastName, or isLastName.
 value argument is not compatible with the underlying field or method parameter, the default implementation will make an effort to
 convert between different Java numeric types (Integer, Double, BigDecimal, etc) as well as between Boolean and Number (true = 1, false = 0).  If any other
 conversion would be necessary, an exception is thrown.
 handleTakeValueForUnboundKey
 if the object implements NSKeyValueCoding.ErrorHandling or throws
 NSKeyValueCoding.UnknownKeyException if the object does not.Note: : The default implementations have significant performance optimizations. To benefit from them, implement NSKeyValueCoding on a custom class as shown above by using the methods in NSKeyValueCoding. DefaultImplementation, or if your class inherits from an WebObjects class that implements NSKeyValueCoding, do not override the inherited implementation. Using a custom implementation incurs significant performance penalties.
takeValueForKey in interface NSKeyValueCodingvalue - the new value for the property named by keykey - identifies the property to changeNSKeyValueCoding.NullValue, 
NSKeyValueCoding.valueForKey(java.lang.String), 
NSKeyValueCoding.DefaultImplementation, 
NSKeyValueCoding.ErrorHandling, 
NSKeyValueCoding.ErrorHandling.handleTakeValueForUnboundKey(java.lang.Object, java.lang.String)
public void takeValueForKeyPath(Object value,
                                String keyPath)
NSKeyValueCodingAdditionskeyPath
 to value. A key path has the form relationship.property
 (with one or more relationships); for example "movieRole.roleName"
 or "movieRole.talent.lastName". The default implementation of
 this method (provided by NSKeyValueCodingAdditions.DefaultImplementation)
 gets the destination object for each relationship using valueForKey,
 and sends the final object a takeValueForKey message with value
 and property.
takeValueForKeyPath in interface NSKeyValueCodingAdditionsvalue - the property identified by keyPath is set to thiskeyPath - identifies the property of an objectNSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String), 
NSKeyValueCodingAdditions.valueForKeyPath(java.lang.String), 
NSKeyValueCodingAdditions.DefaultImplementationpublic String toString()
public void unableToSetNullForKey(String key)
NSKeyValueCoding.ErrorHandlingtakeValueForKey when it is given a null value
 for a scalar property (such as an int or a float).
 The default implementation throws an IllegalArgumentException.
 You might want to implement the method (or override the inherited
 implementation) to handle the request in some other way, such as by
 substituting new Integer(0) or a sentinel value and invoking takeValueForKey
 again.
unableToSetNullForKey in interface NSKeyValueCoding.ErrorHandlingkey - the name of the property which generated this errorNSKeyValueCoding.takeValueForKey(Object value, String key), 
NSKeyValueCoding.DefaultImplementation
public String urlWithRequestHandlerKey(String requestHandlerKey,
                                       String aRequestHandlerPath,
                                       String aQueryString)
cgi-bin/WebObjects for the specified
 request handler. The requestHandlerKey is one of the keys
 registered with WOApplication. The aRequestHandlerPath is any URL
 encoded string.
 The aQueryString is added at the end of the URL behind a "?".
requestHandlerKey - one of the keys provided by WOApplicationaRequestHandlerPath - any URL encoded stringaQueryString - string added at the end of the URL
cgi-bin/WebObjects for the specified request handler(String requestHandlerKey, String aRequestHandlerPath, String aQueryString, boolean isSecure,int somePort), 
WOApplication.registeredRequestHandlerKeys()public Object valueForKey(String key)
NSKeyValueCodingkey.The default implementation provided by NSKeyValueCoding.DefaultImplementation works as follows:
key. For
 example, with a key of "lastName", the method looks for a method named
 getLastName, lastName, or isLastName.canAccessFieldsDirectly returns true, the method searches
 for a field based on key and returns its value
 directly. For the key "lastName", this would be _lastName, _isLastName, lastName, or isLastName.Note: The default implementations have significant performance optimizations. To benefit from them, implement NSKeyValueCoding on a custom class as shown above by using the methods in NSKeyValueCoding.DefaultImplementation, or if your class inherits from an WebObjects class that implements NSKeyValueCoding, do not override the inherited implementation. Using a custom implementation incurs significant performance penalties.
valueForKey in interface NSKeyValueCodingkey - identifies the property to retrieve
key.  Depending on the object you invoke this method upon, null may be replaced with NullValueNSKeyValueCoding.NullValue, 
NSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String), 
NSKeyValueCoding.DefaultImplementation, 
NSKeyValueCoding.ErrorHandling, 
NSKeyValueCoding.ErrorHandling.handleQueryWithUnboundKey(java.lang.String)public Object valueForKeyPath(String keyPath)
NSKeyValueCodingAdditionsvalueForKey,
 and returns the result of a valueForKey message to the final
 object.
valueForKeyPath in interface NSKeyValueCodingAdditionskeyPath - the keypath to evaluate
keyPathNSKeyValueCoding.valueForKey(java.lang.String), 
NSKeyValueCodingAdditions.takeValueForKeyPath(java.lang.Object, java.lang.String), 
NSKeyValueCodingAdditions.DefaultImplementation| 
 | Last updated Thu Oct 21 15:04:16 PDT 2004. | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||