public class ERXComponentUtilities extends Object
Modifier and Type | Field and Description |
---|---|
static WOAssociation |
EMPTY |
static WOAssociation |
FALSE |
static WOAssociation |
TRUE |
static WOAssociation |
ZERO |
Constructor and Description |
---|
ERXComponentUtilities() |
Modifier and Type | Method and Description |
---|---|
static NSMutableDictionary<String,WOAssociation> |
_queryParameterAssociations(NSDictionary<String,WOAssociation> associations,
boolean removeQueryParameterAssociations) |
static NSMutableDictionary |
_queryParametersInComponent(NSMutableDictionary associations,
WOComponent component) |
static void |
appendHtmlAttribute(String key,
WOAssociation association,
WOResponse response,
WOComponent component)
Appends an association as an HTML attribute.
|
static void |
appendHtmlAttributes(NSDictionary<String,WOAssociation> associations,
NSArray<String> excludeKeys,
WOResponse response,
WOComponent component)
Appends a dictionary of associations as HTML attributes.
|
static void |
appendHtmlAttributes(NSDictionary<String,WOAssociation> associations,
WOResponse response,
WOComponent component)
Appends a dictionary of associations as HTML attributes.
|
static void |
appendHtmlAttributes(NSDictionary<String,WOAssociation> associations,
WOResponse response,
WOContext context)
Appends a dictionary of associations as HTML attributes.
|
static <T> NSArray<T> |
arrayValueForBinding(String name,
NSArray<T> defaultValue,
NSDictionary<String,WOAssociation> associations,
WOComponent component)
Retrieves the current array value of the given binding from the component.
|
static NSArray |
arrayValueForBinding(String name,
NSDictionary<String,WOAssociation> associations,
WOComponent component)
Retrieves the current array value of the given binding from the component.
|
static boolean |
bindingIsSettable(String name,
NSDictionary<String,WOAssociation> associations)
Checks if the association for a binding with the given name can assign
values at runtime.
|
static WOAssociation |
bindingNamed(String name,
NSDictionary<String,WOAssociation> associations)
Returns the association for a binding with the given name.
|
static boolean |
booleanValueForBinding(String name,
boolean defaultValue,
NSDictionary<String,WOAssociation> associations,
WOComponent component)
Retrieves the current boolean value of the given binding from the component.
|
static boolean |
booleanValueForBinding(String name,
NSDictionary<String,WOAssociation> associations,
WOComponent component)
Retrieves the current boolean value of the given binding from the component.
|
static boolean |
booleanValueForBinding(WOComponent component,
String bindingName)
Returns the boolean value of a binding.
|
static boolean |
booleanValueForBinding(WOComponent component,
String bindingName,
boolean defaultValue)
Returns the boolean value of a binding.
|
static NSArray<String> |
componentTree()
Returns an array of the current component names.
|
static boolean |
hasBinding(String name,
NSDictionary<String,WOAssociation> associations)
Checks if there is an association for a binding with the given name.
|
static String |
htmlTemplate(String componentName,
NSArray languages)
Returns the contents of the html template for the given component name as
a string.
|
static URL |
htmlTemplateUrl(String componentName,
NSArray languages)
Returns the URL of the html template for the given component name.
|
static WOElement |
inheritTemplateFrom(String componentName,
NSArray<String> languages)
Allows a component to "inherit" the template (.html and .wod files) from another component.
|
static int |
integerValueForBinding(String name,
int defaultValue,
NSDictionary<String,WOAssociation> associations,
WOComponent component)
Retrieves the current int value of the given binding from the component.
|
static <T extends WOComponent> |
pageWithName(Class<T> componentClass)
Calls pageWithName with ERXWOContext.currentContext() for the current
thread.
|
static <T extends WOComponent> |
pageWithName(Class<T> componentClass,
WOContext context)
Returns the component for the given class without having to cast.
|
static NSMutableDictionary<String,WOAssociation> |
queryParameterAssociations(NSDictionary<String,WOAssociation> associations)
Returns the set of ?key=value associations from an associations
dictionary.
|
static NSMutableDictionary<String,WOAssociation> |
queryParameterAssociations(NSMutableDictionary<String,WOAssociation> associations,
boolean removeQueryParameterAssociations)
Returns the set of ?key=value associations from an associations
dictionary.
|
static NSMutableDictionary |
queryParametersInComponent(NSDictionary associations,
WOComponent component)
Returns a query parameter dictionary from a set of ?key=association
WOAssociation dictionary.
|
static NSMutableDictionary |
queryParametersInComponent(NSMutableDictionary associations,
WOComponent component,
boolean removeQueryParametersAssociations)
Returns a query parameter dictionary from a set of ?key=association
WOAssociation dictionary.
|
static void |
setValueForBinding(Object value,
String name,
NSDictionary<String,WOAssociation> associations,
WOComponent component)
Will try to set the given binding in the component to the passed value.
|
static String |
stringValueForBinding(String name,
NSDictionary<String,WOAssociation> associations,
WOComponent component)
Retrieves the current string value of the given binding from the component.
|
static String |
stringValueForBinding(String name,
String defaultValue,
NSDictionary<String,WOAssociation> associations,
WOComponent component)
Retrieves the current string value of the given binding from the component.
|
static String |
template(String componentName,
String extension,
NSArray languages)
Returns the contents of the template for the given component name as a
string.
|
static URL |
templateUrl(String componentName,
String extension,
NSArray languages)
Returns the URL of the template for the given component name.
|
static Object |
valueForBinding(String name,
NSDictionary<String,WOAssociation> associations,
WOComponent component)
Retrieves the current value of the given binding from the component.
|
static Object |
valueForBinding(String name,
Object defaultValue,
NSDictionary<String,WOAssociation> associations,
WOComponent component)
Retrieves the current value of the given binding from the component.
|
public static WOAssociation TRUE
public static WOAssociation FALSE
public static WOAssociation EMPTY
public static WOAssociation ZERO
public static NSMutableDictionary queryParametersInComponent(NSDictionary associations, WOComponent component)
associations
- the set of associationscomponent
- the component to evaluate their values withinpublic static NSMutableDictionary queryParametersInComponent(NSMutableDictionary associations, WOComponent component, boolean removeQueryParametersAssociations)
associations
- the set of associationscomponent
- the component to evaluate their values withinremoveQueryParametersAssociations
- should the entries be removed from the passed-in dictionary?public static NSMutableDictionary _queryParametersInComponent(NSMutableDictionary associations, WOComponent component)
public static NSMutableDictionary<String,WOAssociation> queryParameterAssociations(NSDictionary<String,WOAssociation> associations)
associations
- the associations to enumeratepublic static NSMutableDictionary<String,WOAssociation> queryParameterAssociations(NSMutableDictionary<String,WOAssociation> associations, boolean removeQueryParameterAssociations)
true
, the
corresponding entries will be removed from the associations dictionary
that was passed in.associations
- the associations to enumerateremoveQueryParameterAssociations
- should the entries be removed from the passed-in dictionary?public static NSMutableDictionary<String,WOAssociation> _queryParameterAssociations(NSDictionary<String,WOAssociation> associations, boolean removeQueryParameterAssociations)
public static boolean booleanValueForBinding(WOComponent component, String bindingName)
component
- the componentbindingName
- the name of the boolean bindingpublic static boolean booleanValueForBinding(WOComponent component, String bindingName, boolean defaultValue)
component
- the componentbindingName
- the name of the boolean bindingdefaultValue
- the default value if the binding is nullpublic static URL htmlTemplateUrl(String componentName, NSArray languages)
componentName
- the name of the component to load a template for (without the
.wo)languages
- the list of languages to use for finding componentspublic static URL templateUrl(String componentName, String extension, NSArray languages)
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 componentspublic static String htmlTemplate(String componentName, NSArray languages) throws IOException
componentName
- the name of the component to load a template for (without the
.wo)languages
- the list of languages to use for finding componentsIOException
public static String template(String componentName, String extension, NSArray languages) throws IOException
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 componentsIOException
public static WOElement inheritTemplateFrom(String componentName, NSArray<String> languages)
Usage in your WOComponent subclass:
@Override public WOElement template() { return ERXComponentUtilities.inheritTemplateFrom("AddAddress", session().languages()); }This very simple implementation does have some limitations:
componentName
- the name of the component whose template will be inheritedlanguages
- the list of languages to use for finding componentsWOComponent.template()
public static NSArray<String> componentTree()
public static void appendHtmlAttributes(NSDictionary<String,WOAssociation> associations, WOResponse response, WOContext context)
associations
- the associations dictionaryresponse
- the response to write tocontext
- the contextpublic static void appendHtmlAttributes(NSDictionary<String,WOAssociation> associations, WOResponse response, WOComponent component)
associations
- the associations dictionaryresponse
- the response to write tocomponent
- the component to evaluate the associations withinpublic static void appendHtmlAttributes(NSDictionary<String,WOAssociation> associations, NSArray<String> excludeKeys, WOResponse response, WOComponent component)
associations
- the associations dictionaryexcludeKeys
- the associations to ignoreresponse
- the response to write tocomponent
- the component to evaluate the associations withinpublic static void appendHtmlAttribute(String key, WOAssociation association, WOResponse response, WOComponent component)
key
- the key to appendassociation
- the associationresponse
- the response to write tocomponent
- the component to evaluate the association withinpublic static <T extends WOComponent> T pageWithName(Class<T> componentClass, WOContext context)
T
- the type of component tocomponentClass
- the component class to lookupcontext
- the contextpublic static <T extends WOComponent> T pageWithName(Class<T> componentClass)
T
- the type of component tocomponentClass
- the component class to lookuppublic static boolean hasBinding(String name, NSDictionary<String,WOAssociation> associations)
name
- binding nameassociations
- array of associationstrue
if the association existspublic static WOAssociation bindingNamed(String name, NSDictionary<String,WOAssociation> associations)
null
will be returned.name
- binding nameassociations
- array of associationsnull
public static boolean bindingIsSettable(String name, NSDictionary<String,WOAssociation> associations)
name
- binding nameassociations
- array of associationstrue
if binding is settablepublic static void setValueForBinding(Object value, String name, NSDictionary<String,WOAssociation> associations, WOComponent component)
value
- new value for the bindingname
- binding nameassociations
- array of associationscomponent
- component to set the value inpublic static Object valueForBinding(String name, Object defaultValue, NSDictionary<String,WOAssociation> associations, WOComponent component)
null
the default
value will be returned.name
- binding namedefaultValue
- default valueassociations
- array of associationscomponent
- component to get value frompublic static Object valueForBinding(String name, NSDictionary<String,WOAssociation> associations, WOComponent component)
null
will be returned.name
- binding nameassociations
- array of associationscomponent
- component to get value fromnull
public static String stringValueForBinding(String name, String defaultValue, NSDictionary<String,WOAssociation> associations, WOComponent component)
null
the default
value will be returned.name
- binding namedefaultValue
- default valueassociations
- array of associationscomponent
- component to get value frompublic static String stringValueForBinding(String name, NSDictionary<String,WOAssociation> associations, WOComponent component)
null
will be returned.name
- binding nameassociations
- array of associationscomponent
- component to get value fromnull
public static boolean booleanValueForBinding(String name, boolean defaultValue, NSDictionary<String,WOAssociation> associations, WOComponent component)
name
- binding namedefaultValue
- default valueassociations
- array of associationscomponent
- component to get value frompublic static boolean booleanValueForBinding(String name, NSDictionary<String,WOAssociation> associations, WOComponent component)
false
will be returned.name
- binding nameassociations
- array of associationscomponent
- component to get value fromfalse
public static int integerValueForBinding(String name, int defaultValue, NSDictionary<String,WOAssociation> associations, WOComponent component)
name
- binding namedefaultValue
- default valueassociations
- array of associationscomponent
- component to get value frompublic static <T> NSArray<T> arrayValueForBinding(String name, NSArray<T> defaultValue, NSDictionary<String,WOAssociation> associations, WOComponent component)
null
the default
value will be returned.name
- binding namedefaultValue
- default valueassociations
- array of associationscomponent
- component to get value frompublic static NSArray arrayValueForBinding(String name, NSDictionary<String,WOAssociation> associations, WOComponent component)
null
will be returned.name
- binding nameassociations
- array of associationscomponent
- component to get value fromnull
Copyright © 2002 – 2024 Project Wonder.