Project Wonder 5.0

er.extensions.components
Class ERXComponent

java.lang.Object
  extended by com.webobjects.appserver.WOElement
      extended by com.webobjects.appserver.WOComponent
          extended by er.extensions.components.ERXComponent
All Implemented Interfaces:
com.webobjects.appserver.WOActionResults, com.webobjects.foundation.NSKeyValueCoding, com.webobjects.foundation.NSKeyValueCoding.ErrorHandling, com.webobjects.foundation.NSKeyValueCodingAdditions, com.webobjects.foundation.NSValidation, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
AjaxSocialNetworkLink, AjaxStatelessJSONClient, CCSegmentedSlider, ERAkismet, ERIUIContainer, ERIUIDialogButton, ERIUIPreference, ERIUIPreferenceGroup, ERIUIToggleButton, ERIUIToolBar, ERIUIViewport, ERMODComponent, ERReCaptcha, ERTagCloud, ERTagField, ERXBooleanPopUpButton, ERXFlickrBatchNavigation, ERXNonSynchronizingComponent, ERXRouteURL, ERXSimpleSpamCheck, SEComponent, SEEntitySnapshots, SESnapshotsList

public abstract class ERXComponent
extends com.webobjects.appserver.WOComponent

ERXComponent provides a common base class for WOComponents along with a bunch of miscellaneous handy features.

See Also:
Serialized Form
Author:
mschrag

Nested Class Summary
 
Nested classes/interfaces inherited from class com.webobjects.appserver.WOComponent
com.webobjects.appserver.WOComponent._EventLoggingEnabler, com.webobjects.appserver.WOComponent.Event
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
com.webobjects.foundation.NSKeyValueCodingAdditions.DefaultImplementation, com.webobjects.foundation.NSKeyValueCodingAdditions.Utility
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCoding
com.webobjects.foundation.NSKeyValueCoding._BooleanFieldBinding, com.webobjects.foundation.NSKeyValueCoding._BooleanMethodBinding, com.webobjects.foundation.NSKeyValueCoding._FieldBinding, com.webobjects.foundation.NSKeyValueCoding._ForwardingBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding._MethodBinding, com.webobjects.foundation.NSKeyValueCoding._NumberFieldBinding, com.webobjects.foundation.NSKeyValueCoding._NumberMethodBinding, com.webobjects.foundation.NSKeyValueCoding._ReflectionKeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding.ErrorHandling, com.webobjects.foundation.NSKeyValueCoding.Null, com.webobjects.foundation.NSKeyValueCoding.UnknownKeyException, com.webobjects.foundation.NSKeyValueCoding.ValueAccessor
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSValidation
com.webobjects.foundation.NSValidation._MethodBinding, com.webobjects.foundation.NSValidation._ValidationBinding, com.webobjects.foundation.NSValidation.DefaultImplementation, com.webobjects.foundation.NSValidation.Utility, com.webobjects.foundation.NSValidation.ValidationException
 
Field Summary
protected  com.webobjects.foundation.NSMutableDictionary _dynamicBindings
           
 
Fields inherited from class com.webobjects.appserver.WOComponent
_Extension, _IsEventLoggingEnabled, _keyAssociations
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding.ErrorHandling
_CLASS
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
_CLASS, _KeyPathSeparatorChar, KeyPathSeparator
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding
NullValue
 
Fields inherited from interface com.webobjects.foundation.NSValidation
_CLASS
 
Constructor Summary
ERXComponent(com.webobjects.appserver.WOContext context)
          Constructs a new ERXComponent.
 
Method Summary
 void _awakeInContext(com.webobjects.appserver.WOContext aArg0)
           
protected  void _checkAccess()
          _checkAccess is called prior to all three phases of the R-R loop to ensure that the user has permission to access this component.
protected  java.lang.String _frameworkName()
          Returns the name of this component's framework or "app" if frameworkName() returns null.
protected  void _includeCSSResources(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context)
           Injects per-component CSS dependencies into the head tag based on the definitions in useDefaultComponentCSS(), defaultCSSPath(), primaryCSSFile(), and additionalCSSFiles().
protected  void _includeJavascriptResources(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context)
           Injects per-component javascript dependencies into the head tag based on the definitions in useDefaultComponentJavascript(), defaultJavascriptPath(), primaryJavascriptFile(), and additionalJavascriptFiles().
protected  com.webobjects.foundation.NSArray<java.lang.String> additionalCSSFiles()
          Returns an array of additional CSS files for this component, or null (or empty array) if there aren't any.
protected  com.webobjects.foundation.NSArray<java.lang.String> additionalJavascriptFiles()
          Returns an array of additional Javascript files for this component, or null (or empty array) if there aren't any.
 void appendToResponse(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context)
          Calls _checkAccess prior to super.appendToResponse and adds support for ClickToOpen (TM).
protected  boolean booleanValueForBinding(java.lang.String binding)
          Resolves a given binding as a boolean value.
protected  boolean booleanValueForBinding(java.lang.String binding, boolean defaultValue)
          Resolves a given binding as a boolean value.
protected  boolean booleanValueForBinding(java.lang.String binding, ERXUtilities.BooleanOperation defaultValue)
          Resolves a given binding as a boolean value with the option of specifing a boolean operator as the default value.
protected  void checkAccess()
          Override to provide custom security checks.
 boolean clickToOpenEnabled(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context)
          Returns whether or not click-to-open should be enabled for this component.
 java.lang.String componentName()
          Returns the name of this component without the package name.
protected  java.lang.String defaultCSSPath()
          Returns the default path prefix for CSS, which will be prepended to all required CSS files for this component.
protected  java.lang.String defaultJavascriptPath()
          Returns the default path prefix for Javascript, which will be prepended to all required Javascript files for this component.
 com.webobjects.foundation.NSMutableDictionary dynamicBindings()
          Lazily initialized dictionary which can be used for the 'item' binding in a repetition for example: 'item = dynamicBindings.myVariable'.
protected  float floatValueForBinding(java.lang.String binding, float defaultValue)
          Resolves a given binding as a float value.
protected  int intValueForBinding(java.lang.String binding, int defaultValue)
          Resolves a given binding as a int value.
 com.webobjects.appserver.WOActionResults invokeAction(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context)
          Calls _checkAccess prior to super.invokeAction.
protected  boolean isPageAccessAllowed()
          Override and return true for any components to which you would like to allow page level access.
 ERXLocalizer localizer()
          Convenience method to get the localizer.
protected  java.lang.Object objectValueForBinding(java.lang.String binding)
          Resolves a given binding as an object in the normal fashion of calling valueForBinding.
protected  java.lang.Object objectValueForBinding(java.lang.String binding, java.lang.Object defaultValue)
          Resolves a given binding as an object in the normal fashion of calling valueForBinding.
<T extends com.webobjects.appserver.WOComponent>
T
pageWithName(java.lang.Class<T> componentClass)
          This variant of pageWithName provides a Java5 genericized version of the original pageWithName.
protected  void postAppendToResponse(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context)
          Override to hook into appendToResponse after super.appendToResponse.
protected  void preAppendToResponse(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context)
          Override to hook into appendToResponse after security checks but before the super.appendToResponse.
protected  java.lang.String primaryCSSFile()
          Returns the primary CSS file for this component, or null if there isn't one.
protected  java.lang.String primaryJavascriptFile()
          Returns the primary Javascript file for this component, or null if there isn't one.
 void reset()
           
protected  java.lang.String stringValueForBinding(java.lang.String binding)
          Retrieves a given binding and if it is not null then returns toString called on the bound object.
protected  java.lang.String stringValueForBinding(java.lang.String binding, java.lang.String defaultValue)
          Retrieves a given binding and if it is not null then returns toString called on the bound object.
 void takeValuesFromRequest(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context)
          Calls _checkAccess prior to super.takeValuesFromRequest.
protected  boolean useDefaultComponentCSS()
          Returns true if this component provides a default CSS file that has the same name as the component itself.
protected  boolean useDefaultComponentJavascript()
          Returns true if this component provides a default Javascript file that has the same name as the component itself.
 
Methods inherited from class com.webobjects.appserver.WOComponent
_associationWithName, _childTemplate, _componentDefinition, _componentUnroll, _isPage, _setContext, _setIsPage, _setParent, _setSubcomponent, _sleepInContext, _subcomponentForElementWithID, _templateNameForClass, _unroll, application, awake, baseURL, bindingKeys, canAccessFieldsDirectly, canGetValueForBinding, canSetValueForBinding, clone, context, debugString, descriptionForResponse, ensureAwakeInContext, frameworkName, generateResponse, handleQueryWithUnboundKey, handleTakeValueForUnboundKey, hasBinding, hasSession, isCachingEnabled, isEventLoggingEnabled, isStateless, logString, name, pageWithName, parent, path, pathURL, performParentAction, pullValuesFromParent, pushValuesToParent, session, set_componentUnroll, set_unroll, setCachingEnabled, setValueForBinding, sleep, synchronizesVariablesWithBindings, takeValueForKey, takeValueForKeyPath, template, templateWithHTMLString, templateWithName, toString, unableToSetNullForKey, validateTakeValueForKeyPath, validateValueForKey, validationFailedWithException, valueForBinding, valueForKey, valueForKeyPath
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_dynamicBindings

protected com.webobjects.foundation.NSMutableDictionary _dynamicBindings
Constructor Detail

ERXComponent

public ERXComponent(com.webobjects.appserver.WOContext context)
Constructs a new ERXComponent.

Parameters:
context - the WOContext
Method Detail

pageWithName

public <T extends com.webobjects.appserver.WOComponent> T pageWithName(java.lang.Class<T> componentClass)
This variant of pageWithName provides a Java5 genericized version of the original pageWithName. You would call it with: MyNextPage nextPage = pageWithName(MyNextPage.class);

Type Parameters:
T - the type of component to create
Parameters:
componentClass - the Class of the component to load
Returns:
an instance of the requested component class

_awakeInContext

public void _awakeInContext(com.webobjects.appserver.WOContext aArg0)
Overrides:
_awakeInContext in class com.webobjects.appserver.WOComponent

_checkAccess

protected void _checkAccess()
                     throws java.lang.SecurityException
_checkAccess is called prior to all three phases of the R-R loop to ensure that the user has permission to access this component. You should override checkAccess to implement addition security checks.

Throws:
java.lang.SecurityException - if the user does not have permission

takeValuesFromRequest

public void takeValuesFromRequest(com.webobjects.appserver.WORequest request,
                                  com.webobjects.appserver.WOContext context)
Calls _checkAccess prior to super.takeValuesFromRequest.

Overrides:
takeValuesFromRequest in class com.webobjects.appserver.WOComponent

invokeAction

public com.webobjects.appserver.WOActionResults invokeAction(com.webobjects.appserver.WORequest request,
                                                             com.webobjects.appserver.WOContext context)
Calls _checkAccess prior to super.invokeAction.

Overrides:
invokeAction in class com.webobjects.appserver.WOComponent

appendToResponse

public void appendToResponse(com.webobjects.appserver.WOResponse response,
                             com.webobjects.appserver.WOContext context)
Calls _checkAccess prior to super.appendToResponse and adds support for ClickToOpen (TM).

Overrides:
appendToResponse in class com.webobjects.appserver.WOComponent

clickToOpenEnabled

public boolean clickToOpenEnabled(com.webobjects.appserver.WOResponse response,
                                  com.webobjects.appserver.WOContext context)
Returns whether or not click-to-open should be enabled for this component. By default this returns ERXClickToOpenSupport.isEnabled().

Parameters:
response - the response
context - the context
Returns:
whether or not click-to-open is enabled for this component

intValueForBinding

protected int intValueForBinding(java.lang.String binding,
                                 int defaultValue)
Resolves a given binding as a int value. Useful for image sizes and the like.

Parameters:
binding - binding to be resolved as a int value.
defaultValue - default int value to be used if the binding is not bound.
Returns:
result of evaluating binding as a int.

floatValueForBinding

protected float floatValueForBinding(java.lang.String binding,
                                     float defaultValue)
Resolves a given binding as a float value.

Parameters:
binding - binding to be resolved as a float value.
defaultValue - default float value to be used if the binding is not bound.
Returns:
result of evaluating binding as a float.

booleanValueForBinding

protected boolean booleanValueForBinding(java.lang.String binding)
Resolves a given binding as a boolean value. Defaults to false.

Parameters:
binding - binding to be resolved as a boolean value.
Returns:
result of evaluating binding as a boolean.

booleanValueForBinding

protected boolean booleanValueForBinding(java.lang.String binding,
                                         boolean defaultValue)
Resolves a given binding as a boolean value.

Parameters:
binding - binding to be resolved as a boolean value.
defaultValue - default boolean value to be used if the binding is not bound.
Returns:
result of evaluating binding as a boolean.

booleanValueForBinding

protected boolean booleanValueForBinding(java.lang.String binding,
                                         ERXUtilities.BooleanOperation defaultValue)
Resolves a given binding as a boolean value with the option of specifing a boolean operator as the default value.

Parameters:
binding - name of the component binding.
defaultValue - boolean operator to be evaluated if the binding is not present.
Returns:
result of evaluating binding as a boolean.

objectValueForBinding

protected java.lang.Object objectValueForBinding(java.lang.String binding)
Resolves a given binding as an object in the normal fashion of calling valueForBinding. This has the one advantage of being able to resolve the resulting object as a {link ERXUtilities$Operation} if it is an Operation and then returning the result as the evaluation of that operation.

Parameters:
binding - name of the component binding.
Returns:
the object for the given binding and in the case that it is an instance of an Operation the value of that operation.

objectValueForBinding

protected java.lang.Object objectValueForBinding(java.lang.String binding,
                                                 java.lang.Object defaultValue)
Resolves a given binding as an object in the normal fashion of calling valueForBinding. This has the one advantage of being able to resolve the resulting object as a {link ERXUtilities$Operation} if it is an Operation and then returning the result as the evaluation of that operation.

Parameters:
binding - name of the component binding.
defaultValue - value to be used if valueForBinding returns null.
Returns:
the object for the given binding and in the case that it is an instance of an Operation the value of that operation.

stringValueForBinding

protected java.lang.String stringValueForBinding(java.lang.String binding)
Retrieves a given binding and if it is not null then returns toString called on the bound object.

Parameters:
binding - to be resolved
Returns:
resolved binding in string format

stringValueForBinding

protected java.lang.String stringValueForBinding(java.lang.String binding,
                                                 java.lang.String defaultValue)
Retrieves a given binding and if it is not null then returns toString called on the bound object.

Parameters:
binding - to be resolved
defaultValue - value to be used if valueForBinding returns null.
Returns:
resolved binding in string format

localizer

public ERXLocalizer localizer()
Convenience method to get the localizer.

Returns:
the current localizer

dynamicBindings

public com.webobjects.foundation.NSMutableDictionary dynamicBindings()
Lazily initialized dictionary which can be used for the 'item' binding in a repetition for example: 'item = dynamicBindings.myVariable'. Useful in rapid turnaround modes where adding a iVar would cause hot code swapping to stop working.

Returns:
a dictionay for use with dynamic bindings

reset

public void reset()
Overrides:
reset in class com.webobjects.appserver.WOComponent

componentName

public java.lang.String componentName()
Returns the name of this component without the package name.

Returns:
the name of this component without the package name

_includeCSSResources

protected void _includeCSSResources(com.webobjects.appserver.WOResponse response,
                                    com.webobjects.appserver.WOContext context)

Injects per-component CSS dependencies into the head tag based on the definitions in useDefaultComponentCSS(), defaultCSSPath(), primaryCSSFile(), and additionalCSSFiles().

If you return true for useDefaultComponentCSS (and do not override primaryCSSFile), this component will inject a reference to defaultCSSPath() + /YourComponentName.css. For instance, if your component is named HeaderFooter, useDefaultComponentCSS will automatically add a reference to defaultCSSPath() + /HeaderFooter.css for you. This allows you to very easily specify per-component CSS files without upper-level components knowing about them. Currently _includeCSSResources does not try to do anything fancy in terms of recombinding CSS files.

Override defaultCSSPath to provide the base path relative to WebServerResources that contains your CSS files. If all of your CSS is in WebServerResources/css, you would return "css" from defaultCSSPath().

If you do not want to use the component's name as the name of the CSS file, you can optionally override primaryCSSFile() to return the name of a specific CSS file, as well as additionalCSSFiles() to return an NSArray of CSS files. All of these file names will be prepended with the defaultCSSPath if it is set.

Parameters:
response - the response to write into
context - the current context

_includeJavascriptResources

protected void _includeJavascriptResources(com.webobjects.appserver.WOResponse response,
                                           com.webobjects.appserver.WOContext context)

Injects per-component javascript dependencies into the head tag based on the definitions in useDefaultComponentJavascript(), defaultJavascriptPath(), primaryJavascriptFile(), and additionalJavascriptFiles().

If you return true for useDefaultComponentJavascript (and do not override primaryJavascriptFile), this component will inject a reference to defaultJavascriptPath() + /YourComponentName.js. For instance, if your component is named HeaderFooter, useDefaultComponentJavascript will automatically add a reference to defaultJavascriptPath() + /HeaderFooter.js for you. This allows you to very easily specify per-component Javascript files without upper-level components knowing about them. Currently _includeJavascriptResources does not try to do anything fancy in terms of recombinding Javascript files.

Override defaultJavascriptPath to provide the base path relative to WebServerResources that contains your Javascript files. If all of your Javascript is in WebServerResources/scripts, you would return "scripts" from defaultJavascriptPath().

If you do not want to use the component's name as the name of the Javascript file, you can optionally override primaryJavascriptFile() to return the name of a specific Javascript file, as well as additionalJavascriptFiles() to return an NSArray of Javascript files. All of these file names will be prepended with the defaultJavascriptPath if it is set.

Parameters:
response - the response to write into
context - the current context

_frameworkName

protected java.lang.String _frameworkName()
Returns the name of this component's framework or "app" if frameworkName() returns null.

Returns:
the name of this component's framework

useDefaultComponentCSS

protected boolean useDefaultComponentCSS()
Returns true if this component provides a default CSS file that has the same name as the component itself.

Returns:
true if this component provides a default-named CSS

defaultCSSPath

protected java.lang.String defaultCSSPath()
Returns the default path prefix for CSS, which will be prepended to all required CSS files for this component. The default is "".

Returns:
the default CSS path.

primaryCSSFile

protected java.lang.String primaryCSSFile()
Returns the primary CSS file for this component, or null if there isn't one. This path will be prepended with defaultCSSPath().

Returns:
the primary CSS file for this component

additionalCSSFiles

protected com.webobjects.foundation.NSArray<java.lang.String> additionalCSSFiles()
Returns an array of additional CSS files for this component, or null (or empty array) if there aren't any. Each path will be prepended with defaultCSSPath().

Returns:
an array of additional CSS files for this component.

useDefaultComponentJavascript

protected boolean useDefaultComponentJavascript()
Returns true if this component provides a default Javascript file that has the same name as the component itself.

Returns:
true if this component provides a default-named Javascript

defaultJavascriptPath

protected java.lang.String defaultJavascriptPath()
Returns the default path prefix for Javascript, which will be prepended to all required Javascript files for this component. The default is "".

Returns:
the default Javascript path.

primaryJavascriptFile

protected java.lang.String primaryJavascriptFile()
Returns the primary Javascript file for this component, or null if there isn't one. This path will be prepended with defaultJavascriptPath().

Returns:
the primary Javascript file for this component

additionalJavascriptFiles

protected com.webobjects.foundation.NSArray<java.lang.String> additionalJavascriptFiles()
Returns an array of additional Javascript files for this component, or null (or empty array) if there aren't any. Each path will be prepended with defaultJavascriptPath().

Returns:
an array of additional Javascript files for this component.

isPageAccessAllowed

protected boolean isPageAccessAllowed()
Override and return true for any components to which you would like to allow page level access.

Returns:
true by default

checkAccess

protected void checkAccess()
                    throws java.lang.SecurityException
Override to provide custom security checks. It is not necessary to call super on this method.

Throws:
java.lang.SecurityException - if the security check fails

preAppendToResponse

protected void preAppendToResponse(com.webobjects.appserver.WOResponse response,
                                   com.webobjects.appserver.WOContext context)
Override to hook into appendToResponse after security checks but before the super.appendToResponse. It is not necessary to call super on this method.

Parameters:
response - the current response
context - the current context

postAppendToResponse

protected void postAppendToResponse(com.webobjects.appserver.WOResponse response,
                                    com.webobjects.appserver.WOContext context)
Override to hook into appendToResponse after super.appendToResponse. It is not necessary to call super on this method.

Parameters:
response - the current response
context - the current context

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.