org.apache.struts.taglib.nested

Class NestedPropertyHelper


public class NestedPropertyHelper
extends java.lang.Object

A simple helper class that does everything that needs to be done to get the nested tag extension to work. The tags will pass in their relative properties and this class will leverage the accessibility of the request object to calculate the nested references and manage them from a central place.

The helper method setNestedProperties(HttpServletRequest,NestedPropertySupport) takes a reference to the tag itself so all the simpler tags can have their references managed from a central location. From here, the reference to a provided name is also preserved for use.

With all tags keeping track of themselves, we only have to seek to the next level, or parent tag, were a tag will append a dot and it's own property.

Version:
$Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
Since:
Struts 1.1

Field Summary

static String
NESTED_INCLUDES_KEY

Method Summary

private static String
calculateRelativeProperty(String property, String parent)
static void
deleteReference(HttpServletRequest request)
Deletes the nested reference from the request object.
static String
getAdjustedProperty(HttpServletRequest request, String property)
Get the adjusted property.
static String
getCurrentName(HttpServletRequest request, NestedNameSupport nested)
Returns the bean name from the request object that the properties are nesting against.
static String
getCurrentProperty(HttpServletRequest request)
Returns the current nesting property from the request object.
private static NestedReference
referenceInstance(HttpServletRequest request)
Pulls the current nesting reference from the request object, and if there isn't one there, then it will create one and set it.
static void
setName(HttpServletRequest request, String name)
Sets the provided name into the request object for reference by the other nested tags.
static void
setNestedProperties(HttpServletRequest request, NestedPropertySupport tag)
Helper method that will set all the relevant nesting properties for the provided tag reference depending on the implementation.
static void
setProperty(HttpServletRequest request, String property)
Sets the provided property into the request object for reference by the other nested tags.

Field Details

NESTED_INCLUDES_KEY

public static final String NESTED_INCLUDES_KEY

Method Details

calculateRelativeProperty

private static String calculateRelativeProperty(String property,
                                                String parent)

deleteReference

public static final void deleteReference(HttpServletRequest request)
Deletes the nested reference from the request object.
Parameters:
request - object to remove the reference from

getAdjustedProperty

public static final String getAdjustedProperty(HttpServletRequest request,
                                               String property)
Get the adjusted property. Apply the provided property, to the property already stored in the request object.
Parameters:
request - to pull the reference from
property - to retrieve the evaluated nested property with
Returns:
String of the final nested property reference.

getCurrentName

public static final String getCurrentName(HttpServletRequest request,
                                          NestedNameSupport nested)
Returns the bean name from the request object that the properties are nesting against.

The requirement of the tag itself could be removed in the future, but is required if support for the tag is maintained.

Parameters:
request - object to fetch the bean reference from
nested - tag from which to start the search from
Returns:
the string of the bean name to be nesting against

getCurrentProperty

public static final String getCurrentProperty(HttpServletRequest request)
Returns the current nesting property from the request object.
Parameters:
request - object to fetch the property reference from
Returns:
String of the bean name to nest against

referenceInstance

private static final NestedReference referenceInstance(HttpServletRequest request)
Pulls the current nesting reference from the request object, and if there isn't one there, then it will create one and set it.
Parameters:
request - object to manipulate the reference into
Returns:
current nesting reference as stored in the request object

setName

public static final void setName(HttpServletRequest request,
                                 String name)
Sets the provided name into the request object for reference by the other nested tags.
Parameters:
request - object to set the new name into
name - String to set the name to

setNestedProperties

public static void setNestedProperties(HttpServletRequest request,
                                       NestedPropertySupport tag)
Helper method that will set all the relevant nesting properties for the provided tag reference depending on the implementation.
Parameters:
request - object to pull references from
tag - to set the nesting values into

setProperty

public static final void setProperty(HttpServletRequest request,
                                     String property)
Sets the provided property into the request object for reference by the other nested tags.
Parameters:
request - object to set the new property into
property - String to set the property to

Copyright B) 2000-2007 - The Apache Software Foundation