net.wotonomy.web
Class WOComponent

java.lang.Object
  extended by net.wotonomy.web.WOElement
      extended by net.wotonomy.web.WOComponent
All Implemented Interfaces:
java.io.Serializable, net.wotonomy.control.EOKeyValueCoding, net.wotonomy.control.EOKeyValueCodingAdditions, net.wotonomy.foundation.NSKeyValueCoding, net.wotonomy.foundation.NSKeyValueCodingAdditions, WOActionResults

public class WOComponent
extends WOElement
implements WOActionResults, net.wotonomy.control.EOKeyValueCodingAdditions, net.wotonomy.control.EOKeyValueCoding

Pure java implementation of WOComponent.

Version:
$Revision: 905 $
Author:
michael@mpowers.net, $Author: cgruber $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.wotonomy.control.EOKeyValueCodingAdditions
net.wotonomy.control.EOKeyValueCodingAdditions.DefaultImplementation, net.wotonomy.control.EOKeyValueCodingAdditions.Utility
 
Nested classes/interfaces inherited from interface net.wotonomy.foundation.NSKeyValueCoding
net.wotonomy.foundation.NSKeyValueCoding.Null
 
Nested classes/interfaces inherited from interface net.wotonomy.foundation.NSKeyValueCoding
net.wotonomy.foundation.NSKeyValueCoding.Null
 
Field Summary
protected  boolean cachingEnabled
           
protected  WOContext context
           
protected  WOComponent parent
           
protected  WOElement template
           
 
Fields inherited from interface net.wotonomy.foundation.NSKeyValueCoding
NullValue
 
Fields inherited from interface net.wotonomy.foundation.NSKeyValueCoding
NullValue
 
Constructor Summary
WOComponent()
          Default constructor.
WOComponent(WOContext aContext)
          Constructor specifying a context.
 
Method Summary
 void appendToResponse(WOResponse aResponse, WOContext aContext)
          This method is called on all elements of the content tree to build a response to a user request.
 WOApplication application()
          Returns the application containing this instance of the class.
 void awake()
          Called at the beginning of a request-response cycle.
 java.lang.String baseURL()
          Returns the URL for this component, relative to the server's document root on the server's file system.
 boolean canGetValueForBinding(java.lang.String aBinding)
          Returns whether this component has a readable value that maps to the specified binding.
 boolean canSetValueForBinding(java.lang.String aBinding)
          Returns whether this component has a writable value that maps to the specified binding.
 WOContext context()
          Returns the current context for this component.
static void debugString(java.lang.String aString)
           
 java.lang.String descriptionForResponse(WOResponse aResponse, WOContext aContext)
          Called on the component that represents the requested page.
 java.lang.String frameworkName()
          Returns the name of the framework that contains this component, or null if the component does not belong to a framework.
 WOResponse generateResponse()
          Generates a WOResponse and calls appendToResponse() on it.
 java.lang.Object handleQueryWithUnboundKey(java.lang.String aKey)
           
 void handleTakeValueForUnboundKey(java.lang.Object aValue, java.lang.String aKey)
           
 boolean hasBinding(java.lang.String aBinding)
          Returns whether this component has the specified binding.
 boolean hasSession()
          Returns whether a session has been created for this user.
 WOActionResults invokeAction(WORequest aRequest, WOContext aContext)
          This method is called on all objects and elements of the application until a non-null value is returned.
 boolean isCachingEnabled()
          Returns whether templates are cached.
 boolean isStateless()
          Returns whether this component should be considered stateless.
static void logString(java.lang.String aString)
           
 java.lang.String name()
          Returns the name of the component, which is usually just the class name.
 WOComponent pageWithName(java.lang.String aName)
          Returns a new WOComponent with the specified name.
 WOComponent parent()
          Returns this component's parent component, or null if none.
 java.lang.String path()
          Returns the system-dependent file path to the current component directory, including the ".wo" extension.
 WOActionResults performParentAction(java.lang.String anAction)
          Invokes the specified action on this component's parent.
 void pullValuesFromParent()
          Called before each phase of the request-response cycle, if synchronizesVariablesWithBindings is true and the component is not stateless.
 void pushValuesToParent()
          Called after each phase of the request-response cycle, if synchronizesVariablesWithBindings is true and the component is not stateless.
 void reset()
          Called only on stateless components to tell themselves to reset themselves for another invocation using a different context.
 WOSession session()
          Returns the current session object, creating it if it doesn't exist.
 void setCachingEnabled(boolean enabled)
          Sets whether templates are cached.
 void setValueForBinding(java.lang.Object aValue, java.lang.String aBinding)
          Sets the value for the specified binding for this component.
 void sleep()
          Called at the end of a request-response cycle.
 java.lang.Object storedValueForKey(java.lang.String aKey)
           
 boolean synchronizesVariablesWithBindings()
          Returns true if this component should get and set values in its parent.
 void takeStoredValueForKey(java.lang.Object aValue, java.lang.String aKey)
           
 void takeValueForKey(java.lang.Object aValue, java.lang.String aKey)
           
 void takeValueForKeyPath(java.lang.Object aValue, java.lang.String aPath)
           
 void takeValuesFromDictionary(java.util.Map aValueMap)
           
 void takeValuesFromRequest(WORequest aRequest, WOContext aContext)
          This method is called to retrieve user-entered data from the request.
 WOElement template()
          Returns the root of the tree of elements produced by parsing the templates in the component directory for this component.
static WOElement templateWithHTMLString(java.lang.String anHTMLString, java.lang.String aDeclaration, java.util.List aLanguageList)
          Returns the root of the tree of elements produced by parsing the specfified HTML string and bindings declaration string.
 WOElement templateWithName(java.lang.String aComponentName)
          Deprecated. Use template() instead.
 void unableToSetNullForKey(java.lang.String aKey)
           
 java.lang.Object validateTakeValueForKeyPath(java.lang.Object aValue, java.lang.String aKey)
           
 void validationFailedWithException(java.lang.Throwable anException, java.lang.Object aValue, java.lang.String aPath)
          Called when exceptions are raised by assigning values to this object.
 java.lang.Object valueForBinding(java.lang.String aBinding)
          Returns the value for the specified binding for this component.
 java.lang.Object valueForKey(java.lang.String aKey)
           
 java.lang.Object valueForKeyPath(java.lang.String aPath)
           
 net.wotonomy.foundation.NSDictionary valuesForKeys(java.util.List aKeyList)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected transient WOContext context

cachingEnabled

protected boolean cachingEnabled

template

protected WOElement template

parent

protected WOComponent parent
Constructor Detail

WOComponent

public WOComponent()
Default constructor. Deprecated in latest spec.


WOComponent

public WOComponent(WOContext aContext)
Constructor specifying a context.

Method Detail

name

public java.lang.String name()
Returns the name of the component, which is usually just the class name.


path

public java.lang.String path()
Returns the system-dependent file path to the current component directory, including the ".wo" extension.


baseURL

public java.lang.String baseURL()
Returns the URL for this component, relative to the server's document root on the server's file system. This is not an http url.


frameworkName

public java.lang.String frameworkName()
Returns the name of the framework that contains this component, or null if the component does not belong to a framework. This currently returns the package path of the class, or null if it does not belong to a package.


setCachingEnabled

public void setCachingEnabled(boolean enabled)
Sets whether templates are cached. If true, templates will only be read once per application lifetime. Otherwise, templates will be read each time this class is instantiated. Defaults to false.


isCachingEnabled

public boolean isCachingEnabled()
Returns whether templates are cached. If true, templates are read once per application lifetime. Otherwise, templates are read each time this class is instantiated.


template

public WOElement template()
Returns the root of the tree of elements produced by parsing the templates in the component directory for this component.


templateWithName

public WOElement templateWithName(java.lang.String aComponentName)
Deprecated. Use template() instead.

Returns the root of the tree of elements produced by parsing the templates in the component directory for the named component.


templateWithHTMLString

public static WOElement templateWithHTMLString(java.lang.String anHTMLString,
                                               java.lang.String aDeclaration,
                                               java.util.List aLanguageList)
Returns the root of the tree of elements produced by parsing the specfified HTML string and bindings declaration string. Note: language list is currently ignored.


awake

public void awake()
Called at the beginning of a request-response cycle. Override to perform any necessary initialization. This implementation does nothing.


takeValuesFromRequest

public void takeValuesFromRequest(WORequest aRequest,
                                  WOContext aContext)
Description copied from class: WOElement
This method is called to retrieve user-entered data from the request. WOElements should retrieve data from the request based on their elementID and set values in the context's current WOComponent, typically those values that are associated with the element in the binding. This implementation does nothing.

Overrides:
takeValuesFromRequest in class WOElement

invokeAction

public WOActionResults invokeAction(WORequest aRequest,
                                    WOContext aContext)
Description copied from class: WOElement
This method is called on all objects and elements of the application until a non-null value is returned. WOElements should first check to see if they are the target of an action by checking the WOContext's senderID to see if it matches this element's elementID. If this element is the target, it should perform an appropriate action on the context's current WOComponent, usually the action specified in the binding, and return the result of that action. This implementation returns null.

Overrides:
invokeAction in class WOElement

appendToResponse

public void appendToResponse(WOResponse aResponse,
                             WOContext aContext)
Description copied from class: WOElement
This method is called on all elements of the content tree to build a response to a user request. The message should be forwarded to any child elements so that the entire tree is traversed. This implementation does nothing.

Overrides:
appendToResponse in class WOElement

sleep

public void sleep()
Called at the end of a request-response cycle. Override to perform any necessary clean-up. This implementation does nothing.


generateResponse

public WOResponse generateResponse()
Generates a WOResponse and calls appendToResponse() on it.

Specified by:
generateResponse in interface WOActionResults

parent

public WOComponent parent()
Returns this component's parent component, or null if none.


performParentAction

public WOActionResults performParentAction(java.lang.String anAction)
Invokes the specified action on this component's parent. Variables will be synchronized when this method returns.


pullValuesFromParent

public void pullValuesFromParent()
Called before each phase of the request-response cycle, if synchronizesVariablesWithBindings is true and the component is not stateless.


pushValuesToParent

public void pushValuesToParent()
Called after each phase of the request-response cycle, if synchronizesVariablesWithBindings is true and the component is not stateless.


isStateless

public boolean isStateless()
Returns whether this component should be considered stateless. Stateless components are shared between sessions to conserve memory. This implementation returns false; override to return true.


reset

public void reset()
Called only on stateless components to tell themselves to reset themselves for another invocation using a different context. This implementation does nothing.


application

public WOApplication application()
Returns the application containing this instance of the class.


hasSession

public boolean hasSession()
Returns whether a session has been created for this user.


session

public WOSession session()
Returns the current session object, creating it if it doesn't exist.


context

public WOContext context()
Returns the current context for this component.


pageWithName

public WOComponent pageWithName(java.lang.String aName)
Returns a new WOComponent with the specified name. If null, returns the component named "Main". If the named component doesn't exist, returns null.


validationFailedWithException

public void validationFailedWithException(java.lang.Throwable anException,
                                          java.lang.Object aValue,
                                          java.lang.String aPath)
Called when exceptions are raised by assigning values to this object. This implementation does nothing, but subclasses may override to do something useful.


descriptionForResponse

public java.lang.String descriptionForResponse(WOResponse aResponse,
                                               WOContext aContext)
Called on the component that represents the requested page. Override to return logging information specific to your component. This implementation returns the component's name.


synchronizesVariablesWithBindings

public boolean synchronizesVariablesWithBindings()
Returns true if this component should get and set values in its parent. This implementation returns true. Override to create a component that does not automatically synchronize bindings with its parent, useful if you wish to handle synchronization manually.


canGetValueForBinding

public boolean canGetValueForBinding(java.lang.String aBinding)
Returns whether this component has a readable value that maps to the specified binding. This implementation calls hasBinding(aBinding).


canSetValueForBinding

public boolean canSetValueForBinding(java.lang.String aBinding)
Returns whether this component has a writable value that maps to the specified binding.


hasBinding

public boolean hasBinding(java.lang.String aBinding)
Returns whether this component has the specified binding.


valueForBinding

public java.lang.Object valueForBinding(java.lang.String aBinding)
Returns the value for the specified binding for this component. The parent component is expected to have set the binding for this component. If no such binding exists, the binding is treated as a property is and obtained using valueForKey. If the property is not found, this method returns null.


setValueForBinding

public void setValueForBinding(java.lang.Object aValue,
                               java.lang.String aBinding)
Sets the value for the specified binding for this component. The parent component is expected to have set the binding for this component. If no such binding exists, the binding is treated as a property and is set using takeValueForKey. If the property is not found, this method fails silently.


logString

public static void logString(java.lang.String aString)

debugString

public static void debugString(java.lang.String aString)

valueForKeyPath

public java.lang.Object valueForKeyPath(java.lang.String aPath)
Specified by:
valueForKeyPath in interface net.wotonomy.foundation.NSKeyValueCodingAdditions

takeValueForKeyPath

public void takeValueForKeyPath(java.lang.Object aValue,
                                java.lang.String aPath)
Specified by:
takeValueForKeyPath in interface net.wotonomy.foundation.NSKeyValueCodingAdditions

valuesForKeys

public net.wotonomy.foundation.NSDictionary valuesForKeys(java.util.List aKeyList)
Specified by:
valuesForKeys in interface net.wotonomy.foundation.NSKeyValueCodingAdditions

takeValuesFromDictionary

public void takeValuesFromDictionary(java.util.Map aValueMap)
Specified by:
takeValuesFromDictionary in interface net.wotonomy.foundation.NSKeyValueCodingAdditions

valueForKey

public java.lang.Object valueForKey(java.lang.String aKey)
Specified by:
valueForKey in interface net.wotonomy.control.EOKeyValueCoding
Specified by:
valueForKey in interface net.wotonomy.foundation.NSKeyValueCoding

takeValueForKey

public void takeValueForKey(java.lang.Object aValue,
                            java.lang.String aKey)
Specified by:
takeValueForKey in interface net.wotonomy.control.EOKeyValueCoding
Specified by:
takeValueForKey in interface net.wotonomy.foundation.NSKeyValueCoding

storedValueForKey

public java.lang.Object storedValueForKey(java.lang.String aKey)
Specified by:
storedValueForKey in interface net.wotonomy.control.EOKeyValueCoding
Specified by:
storedValueForKey in interface net.wotonomy.foundation.NSKeyValueCoding

takeStoredValueForKey

public void takeStoredValueForKey(java.lang.Object aValue,
                                  java.lang.String aKey)
Specified by:
takeStoredValueForKey in interface net.wotonomy.control.EOKeyValueCoding
Specified by:
takeStoredValueForKey in interface net.wotonomy.foundation.NSKeyValueCoding

handleQueryWithUnboundKey

public java.lang.Object handleQueryWithUnboundKey(java.lang.String aKey)
Specified by:
handleQueryWithUnboundKey in interface net.wotonomy.control.EOKeyValueCoding
Specified by:
handleQueryWithUnboundKey in interface net.wotonomy.foundation.NSKeyValueCoding

handleTakeValueForUnboundKey

public void handleTakeValueForUnboundKey(java.lang.Object aValue,
                                         java.lang.String aKey)
Specified by:
handleTakeValueForUnboundKey in interface net.wotonomy.control.EOKeyValueCoding
Specified by:
handleTakeValueForUnboundKey in interface net.wotonomy.foundation.NSKeyValueCoding

unableToSetNullForKey

public void unableToSetNullForKey(java.lang.String aKey)
Specified by:
unableToSetNullForKey in interface net.wotonomy.control.EOKeyValueCoding
Specified by:
unableToSetNullForKey in interface net.wotonomy.foundation.NSKeyValueCoding

validateTakeValueForKeyPath

public java.lang.Object validateTakeValueForKeyPath(java.lang.Object aValue,
                                                    java.lang.String aKey)


Copyright © 2006 null. All Rights Reserved.