|
WebObjects 5.4.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.appserver.WOSession
public class WOSession
WOSession objects represent periods of user interaction during which access to a WebObjects application and its resources is granted to a particular client (typically a browser). An application can have many concurrent sessions, each with its own special "view" of the application and its own set of data values. For example: one client can be accessing a "catalog" application, navigating from page to page and filling a virtual shopping cart with items for purchase. Another client can be accessing the same application at the same time, but visiting different pages and placing different items in his or her shopping cart. Neither client will see anything to indicate that they are not the only person using the application.
Perhaps the most important purpose of a WOSession object is to encapsulate state for a user session. After the application handles a request, it stores the WOSession until the next request in the session occurs. All of the information that is important for maintaining continuity throughout the session is preserved, as is the integrity of session data. This data not only persists between requests but is kept separate from that of all other sessions.
The application uses a session ID to identify a session object. Upon receiving a request that is not identified with a session ID, the application creates a new session and assigns it a session ID -- a unique, randomly generated string. This session ID will appear in the URL between the application name and the page name.
When you develop an application, you identify data with session-wide scope by declaring instance variables in your subclass of WOSession. As the client interacts with the application, before the end of each cycle of the request-response loop, you should ensure that the instance variables hold the current session values.
At the end of each cycle of the request-response loop, the application stores the WOSession object according to the storage strategy implemented by the chosen WOSessionStore. When the application receives the next request in a given session, it restores the WOSession, using the session ID stored in the request as key. To be stored and restored according to any WOSessionStore strategy, a WOSession must be convertible to a stream. To accomplish this, WOSession implements the interface java.io.Serializable; any custom subclasses should also do so.
Because storage of sessions in application memory can consume large amounts of memory over time, WOSession includes methods for controlling the lifespan of session objects. The setTimeOut
method sets a period of inactivity after which the session is terminated. The
terminate
method explicitly ends a session.
The WOSession class provides several other methods useful for tasks ranging from localization to database access:
takeValuesFromRequest, invokeAction
, and appendToResponse
) as well as awake
and sleep
.defaultEditingContext
method gives each WOSession object in an application its own Enterprise Objects editing context.setObjectForKey
and objectForKey
it can store and retrieve values as needed. This mechanism is
especially useful for reusable components.setLanguages
method you can store a list of the languages supported by the session. The sequence of language strings in the list indicates the order of language preference for a particular
session. Several resource-access methods in WOResourceManager, WOApplication, and WOComponent refer to the languages
array when they locate such things as localized strings, images, and sounds.setDistributionEnabled
method. If the flag set by this method is false
, transactions of the session are restricted to a single application instance. If this is the case, the application instance number as
well as the application host name are appended to the URL.
WOSession.setTimeOut(double seconds)
,
WOSession.terminate()
,
WOSession.takeValuesFromRequest(WORequest aRequest, WOContext aContext)
,
WOSession.invokeAction(WORequest aRequest, WOContext aContext)
,
WOSession.appendToResponse(WOResponse aResponse, WOContext aContext)
,
WOSession.awake()
,
WOSession.sleep()
,
WOSession.defaultEditingContext()
,
WOSession.setObjectForKey(Object anObject, String key)
,
WOSession.objectForKey(String key)
,
WOSession.setLanguages(NSArray languages)
,
WOSession.languages()
,
WOSession.setDistributionEnabled(boolean aFlag)
,
WOSessionStore
,
Serialized FormNested Class Summary | |
---|---|
static class |
WOSession.PageFragmentCache
Used primarily in Ajax style page caching. |
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions |
---|
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility |
Field Summary | |
---|---|
static String |
SessionDidCreateNotification
Sent at the end of session creation (including awake ). |
static String |
SessionDidRestoreNotification
Sent after the session is fully restored (including awake ). |
static String |
SessionDidTimeOutNotification
Sent when a session times out but before it is released. |
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions |
---|
KeyPathSeparator |
Constructor Summary | |
---|---|
WOSession()
Creates a WOSession with a randomly generated session ID and a session time-out of WOApplication.sessionTimeOut() seconds. |
|
WOSession(String aSessionID)
Creates a WOSession with session ID aSessionId and a session time-out of WOApplication.sessionTimeOut() seconds. |
Method Summary | |
---|---|
boolean |
allowedToViewEvents()
Returns whether or not the session is allowed to view the WOEvents* pages. |
boolean |
allowedToViewStatistics()
Returns whether or not the session is allowed to view the WOStats page. |
void |
appendToResponse(WOResponse aResponse,
WOContext aContext)
Invoked on the WOSession object during the final phase of the request-response loop. |
void |
awake()
Invoked on the WOSession object at the beginning of a WOSession's involvement in a cycle of the request-response loop, giving the WOSession an opportunity to initialize its instance variables or perform setup operations. |
static boolean |
canAccessFieldsDirectly()
Return true in all cases, indicating that key-value coding is allowed to access fields in this object if an appropriate accessor method isn't present. |
Object |
clone()
|
WOContext |
context()
Returns the WOContext object for the current transaction. |
static void |
debugString(String string)
Deprecated. use com.webobjects.foundation.NSLog instead |
EOEditingContext |
defaultEditingContext()
Returns the default EOEditingContext for the receiver. |
String |
domainForIDCookies()
Returns the path that will be used when creating the rendevous cookie for the application to use with the cookie mechanism for storing session and instance IDs This path is lazily created the first time this method is called using the current request's adaptorPrefix and the
application name, including the .woa extension. |
NSTimestamp |
expirationDateForIDCookies()
Deprecated. this method is deprecated should not be used |
protected WOComponent |
getPageFromPageCacheForContextID(String aContextID)
Gets the page from the Page Cache. |
protected WOComponent |
getPageFromPageFragmentCacheForContextID(String contextID)
Gets the page from the Page Fragment Cache. |
Object |
handleQueryWithUnboundKey(String key)
Invoked from valueForKey when it finds no property binding for key . |
void |
handleTakeValueForUnboundKey(Object value,
String key)
Invoked from takeValueForKey when it finds no property binding for key . |
WOActionResults |
invokeAction(WORequest aRequest,
WOContext aContext)
Invoked on the WOSession object during the middle phase of the request-response loop. |
boolean |
isDistributionEnabled()
Returns false by default, since the default WOSessionStore does not support distributed sessions. |
boolean |
isTerminating()
Returns whether or not the receiver is in the process of terminating. |
Enumeration |
keyEnumerator()
Returms an enumerator of the keys in the component state dictionary. |
Set |
keySet()
Returms a keys sets in the component state dictionary. |
NSArray |
languages()
Returns an NSArray of languages for which the session is localized. |
boolean |
lockDefaultEditingContext()
Return true if we lock the default editing context in the awake/sleep phases. |
static void |
logString(String string)
Deprecated. use com.webobjects.foundation.NSLog instead |
EOEditingContext |
newDefaultEditingContext()
Create a new editing context. |
Object |
objectForKey(String aKey)
Returns an Object stored in the session under a given key. |
void |
removeObjectForKey(String aKey)
Removes the Object stored in the session under a given key. |
WOComponent |
restorePageForContextID(String aContextID)
This method attempts to restore an existing page. |
void |
savePage(WOComponent aPage)
Saves the page instance aPage in the session's page cache. |
protected void |
savePageInPageCache(WOComponent aPage)
Saves the page instance aPage in the session's page cache. |
protected void |
savePageInPageFragmentCache(WOComponent page)
Saves the page instance aPage in the session's page fragment cache. |
void |
savePageInPermanentCache(WOComponent aPageComponent)
Puts aPageComponent into the permanent page cache. |
String |
sessionID()
Return the receivers sessionID . |
void |
setDefaultEditingContext(EOEditingContext editingContext)
Sets the editing context to be returned by defaultEditingContext . |
void |
setDistributionEnabled(boolean aFlag)
Enables or disables the distribution mechanism that effects load balancing among multiple application instances. |
void |
setLanguages(NSArray someLanguages)
Sets the languages for which the session is localized. |
void |
setObjectForKey(Object anObject,
String aKey)
Stores an Object within the session under a given key. |
void |
setStoresIDsInCookies(boolean aFlag)
Enables or disables the use of cookies for storing the session and instance IDs. |
void |
setStoresIDsInURLs(boolean aFlag)
Enables or disables the use of URLs for storing the session and instance IDs. |
void |
setTimeOut(double aTimeInterval)
Set the session time-out in seconds. |
void |
sleep()
Invoked at the conclusion of each request-response loop in which the session is involved, giving the WOSession the opportunity to clean up objects initialized in the awake method. |
NSArray |
statistics()
Returns a list of pages accessed by this session, ordered from first to most recently accessed. |
boolean |
storesIDsInCookies()
Returns whether the cookie mechanism for storing session and instance IDs is enabled. |
boolean |
storesIDsInURLs()
Returns whether the URL mechanism for storing session and instance IDs is enabled. |
void |
takeValueForKey(Object value,
String key)
Sets the value for the property identified by key to value . |
void |
takeValueForKeyPath(Object value,
String keyPath)
Sets the value for the property identified by keyPath
to value . |
void |
takeValuesFromRequest(WORequest aRequest,
WOContext aContext)
Invoked on the WOSession object during the first phase of the the request-response loop. |
void |
terminate()
Causes the session to terminate after the conclusion of the current request-response loop. |
double |
timeOut()
Returns the interval in seconds during which the session can remain idle before it times out. |
int |
timeOutForIDCookies()
Deprecated. this method is deprecated should not be used |
long |
timeOutMillis()
Returns the interval in milliseconds during which the session can remain idle before it times out. |
String |
toString()
Returns a string representation of the receiver, including the session ID, the session time-out and a number of the more important state fields. |
void |
unableToSetNullForKey(String key)
Invoked from takeValueForKey when it is given a null value for a scalar property (such as an int or a float ). |
void |
validateEventsLogin(String password,
String username)
Validates the username and password used to access the WOEvents* pages. |
void |
validateStatisticsLogin(String password,
String username)
Validates the username and password used to access the WOStats page. |
void |
validationFailedWithException(Throwable t,
Object value,
String keyPath,
WOComponent component)
Handle an exception thrown as a result of validation failure. |
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 |
Field Detail |
---|
public static final String SessionDidTimeOutNotification
public static final String SessionDidRestoreNotification
awake
). The object of the notification is the session instance.
public static final String SessionDidCreateNotification
awake
). The object of the notification is the session instance.
Constructor Detail |
---|
public WOSession()
WOApplication.sessionTimeOut()
seconds. The isDistributionEnabled
flag is set to false
, meaning that each request in the session will be handled by the same
application instance.
WOSession.isDistributionEnabled()
,
WOSession.setDistributionEnabled(boolean aFlag)
,
WOApplication.sessionTimeOut()
public WOSession(String aSessionID)
aSessionId
and a session time-out of WOApplication.sessionTimeOut()
seconds. The isDistributionEnabled
flag is set to false
, meaning that each request in the session will be handled by the same
application instance.
aSessionID
- the session ID providedWOSession.isDistributionEnabled()
,
WOSession.setDistributionEnabled(boolean aFlag)
,
WOApplication.sessionTimeOut()
Method Detail |
---|
public Object clone()
clone
in class Object
public String toString()
toString
in class Object
public String sessionID()
sessionID
. This ID may be stored in the URL, or in a cookie. If it is in the URL, it will apear after the request handler key.
The sessionID
does not change during the life of the session.
Unless the receiver is a copy of another session, or was created with a specified sessionID
, the sessionID
will be a unique randomly generated String.
public void setDistributionEnabled(boolean aFlag)
When false
, generated URLs include the application instance number. The web server adaptor then uses this number to route the request to a specific application instance.
When true
, generated URLs do not contain the application instance number, and the transactions in a session are distributed among application instances based on whichever load balancing algorithm is in use. Returns false
aFlag
- false
if generated URLs should include the application instance
number, true
otherwiseWOSession.isDistributionEnabled()
public boolean isDistributionEnabled()
false
by default, since the default WOSessionStore does not support distributed sessions.
When false
, generated URLs include the application instance number. The web server adaptor then uses this number to route the request to a specific application instance.
When true
, generated URLs do not contain the application instance number, and the transactions in a session are distributed among application instances based on whichever load balancing algorithm is in use.
false
if generated URLs should include the application instance number, true
otherwiseWOSession.setDistributionEnabled(boolean aFlag)
public void setStoresIDsInCookies(boolean aFlag)
If aFlag
is true
, two cookies are created to store session information: a session ID cookie with the name WORequest.SessionIDKey
, and an instance ID cookie with the name WORequest.InstanceKey
.
By default, this mechanism is disabled.
aFlag
- true
if the session ID should be stored using cookies, false
otherwiseWOSession.storesIDsInCookies()
,
WOSession.storesIDsInURLs()
,
WOSession.setStoresIDsInURLs(boolean aFlag)
public boolean storesIDsInCookies()
If true
, two cookies are created to store session information: a session ID cookie with the name WORequest.SessionIDKey
, and an instance ID cookie with the name WORequest.InstanceKey
.
Returns false
by default.
true
if the session ID should be stored using cookies, false
otherwiseWOSession.setStoresIDsInCookies(boolean aFlag)
,
WOSession.storesIDsInURLs()
,
WOSession.setStoresIDsInURLs(boolean aFlag)
@Deprecated public NSTimestamp expirationDateForIDCookies()
null
in all cases@Deprecated public int timeOutForIDCookies()
-1
in all casespublic void setStoresIDsInURLs(boolean aFlag)
By default, this mechanism is enabled.
aFlag
- true
if the session ID should be stored in the URL, false
otherwiseWOSession.storesIDsInCookies()
,
WOSession.setStoresIDsInCookies(boolean aFlag)
,
WOSession.storesIDsInURLs()
public boolean storesIDsInURLs()
Returns true
by default.
true
if the session ID should be stored in the URL, false
otherwiseWOSession.storesIDsInCookies()
,
WOSession.setStoresIDsInCookies(boolean aFlag)
,
WOSession.setStoresIDsInURLs(boolean aFlag)
public String domainForIDCookies()
adaptorPrefix
and the
application name, including the .woa
extension.
WOSession.storesIDsInCookies()
,
WOSession.setStoresIDsInCookies(boolean aFlag)
,
WORequest.adaptorPrefix()
public void terminate()
WOSession.isTerminating()
public boolean isTerminating()
true
, the session will terminate after the conclusion of the current request-response loop.
true
if the receiver will terminate at the end of the current request-response loop, false
otherwiseWOSession.terminate()
public void setTimeOut(double aTimeInterval)
By default, the session time-out is set to the value returned by WOApplication.sessionTimeOut()
.
aTimeInterval
- the number of seconds the session should remain idle before it times outWOSession.timeOut()
,
WOApplication.sessionTimeOut()
public double timeOut()
WOSession.setTimeOut(double aTimeInterval)
public long timeOutMillis()
public void savePageInPermanentCache(WOComponent aPageComponent)
aPageComponent
into the permanent page cache. The permanent page cache is designed to hold components which are frequently accessed. This is useful when you are using frames, since the number of component instances active in a frameset would dramatically reduce the size of
the standard page cache. Objects can fall out of the permanent page cache if the permanent page cache's size is exceeded. Note that the best place to call this method is in your component class' constructor to avoid calling it multiple times for the same object. The latest place this method
should ever invoke is the beginning of the component's appendToResponse
method.
aPageComponent
- any WOComponentWOSession.restorePageForContextID(java.lang.String)
,
WOSession.savePage(com.webobjects.appserver.WOComponent)
,
WOApplication.permanentPageCacheSize()
,
WOApplication.setPermanentPageCacheSize(int anUnsigned)
,
WOComponent.appendToResponse(com.webobjects.appserver.WOResponse, com.webobjects.appserver.WOContext)
public WOComponent restorePageForContextID(String aContextID)
awake
method is called and it is returned; otherwise, null
is returned.
The key to the stored instance is its contextID
, which derives from the transaction's WOContext or WORequest objects. Note: If you wish to use this method to restore a page generated by WOLongResponse, you must be sure to use the sessionID
retrieved during the WOLongResponse's appendToResponse
.
aContextID
- the key to the stored instance
null
if restoration is impossibleWOSession.savePage(WOComponent aPage)
,
WOSession.savePageInPermanentCache(WOComponent aPageComponent)
,
WOSession.sessionID()
,
WOContext.contextID()
protected WOComponent getPageFromPageCacheForContextID(String aContextID)
aContextID
- the key to the stored instance
protected WOComponent getPageFromPageFragmentCacheForContextID(String contextID)
aContextID
- the key to the stored instance
public void savePage(WOComponent aPage)
aPage
in the session's page cache. Invoked automatically if the WOApplication subclass' pageCacheSize
is non-zero. The context ID
for the current transaction should be used as the key for retrieving this instance from the
cache using restorePageForContextID
. This method will take into account the value shouldNotStorePageInBacktrackCache
in the WOContext and store the page either in the backtrack cache or the page fragment cache.
aPage
- the page instanceWOSession.restorePageForContextID(String aContextID)
,
WOSession.savePageInPermanentCache(WOComponent aPageComponent)
,
WOContext.contextID()
,
WOContext.shouldNotStorePageInBacktrackCache()
protected void savePageInPageCache(WOComponent aPage)
aPage
in the session's page cache. Invoked automatically if the WOApplication subclass' pageCacheSize
is non-zero. The context ID
for the current transaction should be used as the key for retrieving this instance from the
cache using restorePageForContextID
.
aPage
- the page instanceWOSession.restorePageForContextID(String aContextID)
,
WOSession.savePageInPermanentCache(WOComponent aPageComponent)
,
WOContext.contextID()
protected void savePageInPageFragmentCache(WOComponent page)
aPage
in the session's page fragment cache. Invoked automatically if the WOApplication subclass' pageCacheSize
is non-zero. The context ID
for the current transaction should be used as the key for retrieving this instance
from the cache using restorePageForContextID
. Page fragments are identified by the pageFragementID
, as only one copy of each fragment is stored in the cache.
page
- the page instanceWOSession.restorePageForContextID(String aContextID)
,
WOSession.savePageInPermanentCache(WOComponent aPageComponent)
,
WOContext.contextID()
,
WOContext.pageFragementID()
public void setLanguages(NSArray someLanguages)
.lproj
directories for localized strings, images, and component definitions.
someLanguages
- the array of languages for the applicationWOSession.languages()
public NSArray languages()
setLanguages
.
WOSession.setLanguages(NSArray languages)
public void setObjectForKey(Object anObject, String aKey)
element ID
. For a specific component instance, such a prefix should remain unique and invariant within a session.
anObject
- Object to be stored in the current sessionaKey
- String key under which to store the objectWOSession.objectForKey(String aKey)
,
WOSession.removeObjectForKey(String aKey)
public Object objectForKey(String aKey)
aKey
- the key under which the object is stored
WOSession.setObjectForKey(Object anObject, String aKey)
,
WOSession.removeObjectForKey(String aKey)
public Set keySet()
public Enumeration keyEnumerator()
public void removeObjectForKey(String aKey)
aKey
- String key under which the Object is storedWOSession.objectForKey(String aKey)
,
WOSession.setObjectForKey(Object anObject, String aKey)
public WOContext context()
WOContext
public void awake()
The default implementation does nothing.
WOSession.sleep()
public void takeValuesFromRequest(WORequest aRequest, WOContext aContext)
The default behavior of WOSession is to invoke takeValuesFromRequest
on the WOComponent object that represents the request.
Subclasses of WOSession can override this method to replace or supplement the default behavior with custom logic.
aRequest
- the request to be processedaContext
- the current context of the transactionWOSession.appendToResponse(WOResponse aResponse, WOContext aContext)
,
WOSession.invokeAction(WORequest aRequest, WOContext aContext)
public WOActionResults invokeAction(WORequest aRequest, WOContext aContext)
invokeAction
method is propagated through the objects of an application, most importantly, the WOElement objects of the request page. The dynamic element on which the
user has acted -- by, for example, clicking a button -- responds by triggering the method in the request WOComponent that is bound to the action.
The default behavior of WOSession is to invoke invokeAction
on the WOComponent object that represents the request.
Subclasses of WOSession can override this method to replace or supplement the default behavior with custom logic.
aRequest
- the WORequest being processedaContext
- the WOContext context in which the request is being processed
WOSession.appendToResponse(WOResponse aResponse, WOContext aContext)
,
WOSession.takeValuesFromRequest(WORequest aRequest, WOContext aContext)
public void appendToResponse(WOResponse aResponse, WOContext aContext)
appendToResponse
on the
WOComponent that represents the response page. Then it records information about the current transaction by invoking recordStatisticsForResponse
and then descriptionForResponse
on the WOStatisticsStore object.
Subclasses of WOSession can override this method to replace or supplement the default behavior with custom logic. Note This method is not called during a direct action request-response loop.
aResponse
- the WOResponseaContext
- the WOContext of the transactionWOSession.invokeAction(WORequest aRequest, WOContext aContext)
,
WOSession.takeValuesFromRequest(WORequest aRequest, WOContext aContext)
,
WOStatisticsStore.recordStatisticsForResponse(WOResponse aResponse , WOContext aContext)
,
WOStatisticsStore.descriptionForResponse(WOResponse aResponse , WOContext aContext)
public void sleep()
The default WOSession implementation does nothing.
WOSession.awake()
public NSArray statistics()
descriptionForResponse
to its WOComponent object. By default, this returns the component's name. If the application keeps a
CLFF log file, this list is recorded in the log file when the session terminates.
WOSession.appendToResponse(WOResponse aResponse, WOContext aContext)
,
WOComponent.descriptionForResponse(WOResponse aResponse, WOContext aContext)
public boolean allowedToViewStatistics()
false
.
By default, this method returns false
.
true
if clients are allowed to view session statisticsWOSession.validateStatisticsLogin(String password, String username)
,
WOSession.allowedToViewEvents()
,
WOSession.validateEventsLogin(String password, String username)
public void validateStatisticsLogin(String password, String username)
WOStatisticsPassword
property.
By default, the username is ignored.
Subclasses of WOSession can override this method to provide application specific login behavior.
password
- input passwordusername
- input user's nameWOSession.allowedToViewStatistics()
,
WOSession.allowedToViewEvents()
,
WOSession.validateEventsLogin(String password, String username)
public void validationFailedWithException(Throwable t, Object value, String keyPath, WOComponent component)
By default, this method invokes your application class' validationFailedWithException
method.
Subclasses of WOSession can override this method to provide application specific behavior.
t
- the exception that was thrownvalue
- the value that was being setkeyPath
- the derived path that was being accessedcomponent
- the component that was being usedWOApplication.validationFailedWithException(Throwable t, Object value, String keyPath, WOComponent component, WOSession session)
public boolean allowedToViewEvents()
false
.
This method returns false
by default.
true
if the session is allowed to view the WOEvents* pagesWOSession.validateEventsLogin(String password, String username)
,
WOSession.allowedToViewStatistics()
,
WOSession.validateStatisticsLogin(String password, String username)
public void validateEventsLogin(String password, String username)
WOEventsPassword
property.
By default, the username is ignored.
Subclasses of WOSession can override this method to provide application specific login behavior.
password
- input passwordusername
- input user's nameWOSession.allowedToViewEvents()
,
WOSession.allowedToViewStatistics()
,
WOSession.validateStatisticsLogin(String password, String username)
@Deprecated public static void logString(String string)
string
- String to be logged@Deprecated public static void debugString(String string)
string
- String to be loggedpublic EOEditingContext defaultEditingContext()
There is only one unique editing context instance per session.
The instance's parent object store is initialized to the default parent object store.
WOSession.setDefaultEditingContext(EOEditingContext editingContext)
public EOEditingContext newDefaultEditingContext()
public void setDefaultEditingContext(EOEditingContext editingContext)
defaultEditingContext
. This can be used to set an editing context initialized with a different parent object store than the default. This is useful when, for instance, each session needs its own login to the database.
Once a default editing context has been established, setDefaultEditingContext
may not be called again. Therefore, to provide your own default editing context, setDefaultEditingContext
must be called before ever calling defaultEditingContext
since
that will lazily establish an editing context.
editingContext
- the EOEditingContext to be used as the defaultWOSession.defaultEditingContext()
public boolean lockDefaultEditingContext()
public static boolean canAccessFieldsDirectly()
true
in all cases, indicating that key-value coding is allowed to access fields in this object if an appropriate accessor method isn't present.
true
in all casespublic Object valueForKey(String key)
NSKeyValueCoding
key
.
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 NSKeyValueCoding
key
- identifies the property to retrieve
key
. Depending on the object you invoke this method upon, null
may be replaced with NullValue
NSKeyValueCoding.NullValue
,
NSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String)
,
NSKeyValueCoding.DefaultImplementation
,
NSKeyValueCoding.ErrorHandling
,
NSKeyValueCoding.ErrorHandling.handleQueryWithUnboundKey(java.lang.String)
public void takeValueForKey(Object value, String key)
NSKeyValueCoding
key
to value
.
The default implementation provided by NSKeyValueCoding.DefaultImplementation works as follows:
set
Key, and invokes it if there is one._set
Key, 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 NSKeyValueCoding
value
- the new value for the property named by key
key
- identifies the property to changeNSKeyValueCoding.NullValue
,
NSKeyValueCoding.valueForKey
,
NSKeyValueCoding.DefaultImplementation
,
NSKeyValueCoding.ErrorHandling
,
NSKeyValueCoding.ErrorHandling.handleTakeValueForUnboundKey(java.lang.Object, java.lang.String)
public Object handleQueryWithUnboundKey(String key)
NSKeyValueCoding.ErrorHandling
valueForKey
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.ErrorHandling
key
- the property name which generated this error
null
that the custom implementation desires. The default implementation throws an exception instead.NSKeyValueCoding.valueForKey
,
NSKeyValueCoding.UnknownKeyException
,
NSKeyValueCoding.DefaultImplementation
public void handleTakeValueForUnboundKey(Object value, String key)
NSKeyValueCoding.ErrorHandling
takeValueForKey
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.ErrorHandling
value
- the new value which could not be setkey
- the name of the property which generated this errorNSKeyValueCoding.takeValueForKey
,
NSKeyValueCoding.UnknownKeyException
,
NSKeyValueCoding.DefaultImplementation
public void unableToSetNullForKey(String key)
NSKeyValueCoding.ErrorHandling
takeValueForKey
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.ErrorHandling
key
- the name of the property which generated this errorNSKeyValueCoding.takeValueForKey
,
NSKeyValueCoding.DefaultImplementation
public Object valueForKeyPath(String keyPath)
NSKeyValueCodingAdditions
valueForKey
,
and returns the result of a valueForKey
message to the final
object.
valueForKeyPath
in interface NSKeyValueCodingAdditions
keyPath
- the keypath to evaluate
keyPath
NSKeyValueCoding.valueForKey(java.lang.String)
,
NSKeyValueCodingAdditions.takeValueForKeyPath(java.lang.Object, java.lang.String)
,
NSKeyValueCodingAdditions.DefaultImplementation
public void takeValueForKeyPath(Object value, String keyPath)
NSKeyValueCodingAdditions
keyPath
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 NSKeyValueCodingAdditions
value
- 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.DefaultImplementation
|
Last updated June 2008 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |