Project Wonder 5.0

er.extensions.components
Class ERXComponentUtilities

java.lang.Object
  extended by er.extensions.components.ERXComponentUtilities

public class ERXComponentUtilities
extends java.lang.Object

ERXComponentUtilities contains WOComponent/WOElement-related utility methods.

Author:
mschrag

Field Summary
static com.webobjects.appserver.WOAssociation EMPTY
           
static com.webobjects.appserver.WOAssociation FALSE
           
static com.webobjects.appserver.WOAssociation TRUE
           
static com.webobjects.appserver.WOAssociation ZERO
           
 
Constructor Summary
ERXComponentUtilities()
           
 
Method Summary
static com.webobjects.foundation.NSMutableDictionary _queryParameterAssociations(com.webobjects.foundation.NSDictionary associations, boolean removeQueryParameterAssociations)
           
static com.webobjects.foundation.NSMutableDictionary _queryParametersInComponent(com.webobjects.foundation.NSMutableDictionary associations, com.webobjects.appserver.WOComponent component)
           
static void appendHtmlAttribute(java.lang.String key, com.webobjects.appserver.WOAssociation association, com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOComponent component)
          Appends an association as an HTML attribute.
static void appendHtmlAttributes(com.webobjects.foundation.NSDictionary<java.lang.String,com.webobjects.appserver.WOAssociation> associations, com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOComponent component)
          Appends a dictionary of associations as HTML attributes.
static void appendHtmlAttributes(com.webobjects.foundation.NSDictionary<java.lang.String,com.webobjects.appserver.WOAssociation> associations, com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context)
          Appends a dictionary of associations as HTML attributes.
static boolean booleanValueForBinding(com.webobjects.appserver.WOComponent component, java.lang.String bindingName)
          Returns the boolean value of a binding.
static boolean booleanValueForBinding(com.webobjects.appserver.WOComponent component, java.lang.String bindingName, boolean defaultValue)
          Returns the boolean value of a binding.
static com.webobjects.foundation.NSArray componentTree()
          Returns an array of the current component names.
static java.lang.String htmlTemplate(java.lang.String componentName, com.webobjects.foundation.NSArray languages)
          Returns the contents of the html template for the given component name as a string.
static java.net.URL htmlTemplateUrl(java.lang.String componentName, com.webobjects.foundation.NSArray languages)
          Returns the URL of the html template for the given component name.
static com.webobjects.appserver.WOElement inheritTemplateFrom(java.lang.String componentName, com.webobjects.foundation.NSArray<java.lang.String> languages)
          Allows a component to "inherit" the template (.html and .wod files) from another component.
static
<T extends com.webobjects.appserver.WOComponent>
T
pageWithName(java.lang.Class<T> componentClass)
          Calls pageWithName with ERXWOContext.currentContext() for the current thread.
static
<T extends com.webobjects.appserver.WOComponent>
T
pageWithName(java.lang.Class<T> componentClass, com.webobjects.appserver.WOContext context)
          Returns the component for the given class without having to cast.
static com.webobjects.foundation.NSMutableDictionary queryParameterAssociations(com.webobjects.foundation.NSDictionary associations)
          Returns the set of ?key=value associations from an associations dictionary.
static com.webobjects.foundation.NSMutableDictionary queryParameterAssociations(com.webobjects.foundation.NSMutableDictionary associations, boolean removeQueryParameterAssociations)
          Returns the set of ?key=value associations from an associations dictionary.
static com.webobjects.foundation.NSMutableDictionary queryParametersInComponent(com.webobjects.foundation.NSDictionary associations, com.webobjects.appserver.WOComponent component)
          Returns a query parameter dictionary from a set of ?key=association WOAssociation dictionary.
static com.webobjects.foundation.NSMutableDictionary queryParametersInComponent(com.webobjects.foundation.NSMutableDictionary associations, com.webobjects.appserver.WOComponent component, boolean removeQueryParametersAssociations)
          Returns a query parameter dictionary from a set of ?key=association WOAssociation dictionary.
static java.lang.String template(java.lang.String componentName, java.lang.String extension, com.webobjects.foundation.NSArray languages)
          Returns the contents of the template for the given component name as a string.
static java.net.URL templateUrl(java.lang.String componentName, java.lang.String extension, com.webobjects.foundation.NSArray languages)
          Returns the URL of the template for the given component name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRUE

public static com.webobjects.appserver.WOAssociation TRUE

FALSE

public static com.webobjects.appserver.WOAssociation FALSE

EMPTY

public static com.webobjects.appserver.WOAssociation EMPTY

ZERO

public static com.webobjects.appserver.WOAssociation ZERO
Constructor Detail

ERXComponentUtilities

public ERXComponentUtilities()
Method Detail

queryParametersInComponent

public static com.webobjects.foundation.NSMutableDictionary queryParametersInComponent(com.webobjects.foundation.NSDictionary associations,
                                                                                       com.webobjects.appserver.WOComponent component)
Returns a query parameter dictionary from a set of ?key=association WOAssociation dictionary.

Parameters:
associations - the set of associations
component - the component to evaluate their values within
Returns:
a dictionary of key=value query parameters

queryParametersInComponent

public static com.webobjects.foundation.NSMutableDictionary queryParametersInComponent(com.webobjects.foundation.NSMutableDictionary associations,
                                                                                       com.webobjects.appserver.WOComponent component,
                                                                                       boolean removeQueryParametersAssociations)
Returns a query parameter dictionary from a set of ?key=association WOAssociation dictionary.

Parameters:
associations - the set of associations
component - the component to evaluate their values within
removeQueryParametersAssociations - should the entries be removed from the passed-in dictionary?
Returns:
dictionary of key-value query parameters

_queryParametersInComponent

public static com.webobjects.foundation.NSMutableDictionary _queryParametersInComponent(com.webobjects.foundation.NSMutableDictionary associations,
                                                                                        com.webobjects.appserver.WOComponent component)

queryParameterAssociations

public static com.webobjects.foundation.NSMutableDictionary queryParameterAssociations(com.webobjects.foundation.NSDictionary associations)
Returns the set of ?key=value associations from an associations dictionary.

Parameters:
associations - the associations to enumerate

queryParameterAssociations

public static com.webobjects.foundation.NSMutableDictionary queryParameterAssociations(com.webobjects.foundation.NSMutableDictionary associations,
                                                                                       boolean removeQueryParameterAssociations)
Returns the set of ?key=value associations from an associations dictionary. If removeQueryParameterAssociations is true, the corresponding entries will be removed from the associations dictionary that was passed in.

Parameters:
associations - the associations to enumerate
removeQueryParameterAssociations - should the entries be removed from the passed-in dictionary?

_queryParameterAssociations

public static com.webobjects.foundation.NSMutableDictionary _queryParameterAssociations(com.webobjects.foundation.NSDictionary associations,
                                                                                        boolean removeQueryParameterAssociations)

booleanValueForBinding

public static boolean booleanValueForBinding(com.webobjects.appserver.WOComponent component,
                                             java.lang.String bindingName)
Returns the boolean value of a binding.

Parameters:
component - the component
bindingName - the name of the boolean binding
Returns:
a boolean

booleanValueForBinding

public static boolean booleanValueForBinding(com.webobjects.appserver.WOComponent component,
                                             java.lang.String bindingName,
                                             boolean defaultValue)
Returns the boolean value of a binding.

Parameters:
component - the component
bindingName - the name of the boolean binding
defaultValue - the default value if the binding is null
Returns:
a boolean

htmlTemplateUrl

public static java.net.URL htmlTemplateUrl(java.lang.String componentName,
                                           com.webobjects.foundation.NSArray languages)
Returns the URL of the html template for the given component name.

Parameters:
componentName - the name of the component to load a template for (without the .wo)
languages - the list of languages to use for finding components
Returns:
the URL to the html template (or null if there isn't one)

templateUrl

public static java.net.URL templateUrl(java.lang.String componentName,
                                       java.lang.String extension,
                                       com.webobjects.foundation.NSArray languages)
Returns the URL of the template for the given component name.

Parameters:
componentName - the name of the component to load a template for (without the .wo)
extension - the file extension of the template (without the dot -- i.e. "html")
languages - the list of languages to use for finding components
Returns:
the URL to the template (or null if there isn't one)

htmlTemplate

public static java.lang.String htmlTemplate(java.lang.String componentName,
                                            com.webobjects.foundation.NSArray languages)
                                     throws java.io.IOException
Returns the contents of the html template for the given component name as a string.

Parameters:
componentName - the name of the component to load a template for (without the .wo)
languages - the list of languages to use for finding components
Returns:
the string contents of the html template (or null if there isn't one)
Throws:
java.io.IOException

template

public static java.lang.String template(java.lang.String componentName,
                                        java.lang.String extension,
                                        com.webobjects.foundation.NSArray languages)
                                 throws java.io.IOException
Returns the contents of the template for the given component name as a string.

Parameters:
componentName - the name of the component to load a template for (without the .wo)
extension - the file extension of the template (without the dot -- i.e. "html")
languages - the list of languages to use for finding components
Returns:
the string contents of the template (or null if there isn't one)
Throws:
java.io.IOException

inheritTemplateFrom

public static com.webobjects.appserver.WOElement inheritTemplateFrom(java.lang.String componentName,
                                                                     com.webobjects.foundation.NSArray<java.lang.String> languages)
Allows a component to "inherit" the template (.html and .wod files) from another component.

Usage in your WOComponent subclass:

 @Override
 public WOElement template() {
     return ERXComponentUtilities.inheritTemplateFrom("AddAddress", session().languages());
 }
 
This very simple implementation does have some limitations:
  1. It can't be used to inherit the template of another component inheriting a template.
  2. It can't handle having two components with the same name in different packages or frameworks
  3. It does not use WO template caching

Parameters:
componentName - the name of the component whose template will be inherited
languages - the list of languages to use for finding components
Returns:
the template from the indicated component
See Also:
WOComponent.template()

componentTree

public static com.webobjects.foundation.NSArray componentTree()
Returns an array of the current component names.


appendHtmlAttributes

public static void appendHtmlAttributes(com.webobjects.foundation.NSDictionary<java.lang.String,com.webobjects.appserver.WOAssociation> associations,
                                        com.webobjects.appserver.WOResponse response,
                                        com.webobjects.appserver.WOContext context)
Appends a dictionary of associations as HTML attributes.

Parameters:
associations - the associations dictionary
response - the response to write to
context - the context

appendHtmlAttributes

public static void appendHtmlAttributes(com.webobjects.foundation.NSDictionary<java.lang.String,com.webobjects.appserver.WOAssociation> associations,
                                        com.webobjects.appserver.WOResponse response,
                                        com.webobjects.appserver.WOComponent component)
Appends a dictionary of associations as HTML attributes.

Parameters:
associations - the associations dictionary
response - the response to write to
component - the component to evaluate the associations within

appendHtmlAttribute

public static void appendHtmlAttribute(java.lang.String key,
                                       com.webobjects.appserver.WOAssociation association,
                                       com.webobjects.appserver.WOResponse response,
                                       com.webobjects.appserver.WOComponent component)
Appends an association as an HTML attribute.

Parameters:
key - the key to append
association - the association
response - the response to write to
component - the component to evaluate the association within

pageWithName

public static <T extends com.webobjects.appserver.WOComponent> T pageWithName(java.lang.Class<T> componentClass,
                                                                              com.webobjects.appserver.WOContext context)
Returns the component for the given class without having to cast. For example: MyPage page = ERXComponentUtilities.pageWithName(MyPage.class, context);

Type Parameters:
T - the type of component to
Parameters:
componentClass - the component class to lookup
context - the context
Returns:
the created component

pageWithName

public static <T extends com.webobjects.appserver.WOComponent> T pageWithName(java.lang.Class<T> componentClass)
Calls pageWithName with ERXWOContext.currentContext() for the current thread.

Type Parameters:
T - the type of component to
Parameters:
componentClass - the component class to lookup
Returns:
the created component

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

Copyright © 2002 – 2007 Project Wonder.