org.apache.beehive.netui.tags
Class AbstractClassicTag

Object
  extended by TagSupport
      extended by BodyTagSupport
          extended by AbstractClassicTag
All Implemented Interfaces:
Serializable, BodyTag, IterationTag, JspTag, Tag, INetuiTag
Direct Known Subclasses:
AbstractCallMethod, ConfigurePopup, DataSourceTag, DeclareBundle, DivPanel, GetData, HtmlBaseTag, HtmlGroupBaseTag, IncludeSection, Message, MessageArg, MethodParameter, Parameter, ParameterMap, RepeaterComponent, RetrievePopupOutput, RewriteName, RewriteURL, ScriptContainer, ScriptHeader, Section, SerializeXML, SetAttribute, Template

public abstract class AbstractClassicTag
extends BodyTagSupport
implements INetuiTag

AbstractBaseTag is the base tag for most of the NetUI tags. This tag provides default behavior and services for NetUI tags. There following categories of services are provided by this tag:

See Also:
Serialized Form

Field Summary
static List DefaultNamingChain
          This List represents the default naming chain for handling dataSource attributes.
protected static String EMPTY_STRING
          String constant for the empty string.
static String NETUI_UNIQUE_CNT
          This is the name of a request scoped attribute which creates a unique id for processing a request.
 
Fields inherited from class BodyTagSupport
bodyContent
 
Fields inherited from class TagSupport
id, pageContext
 
Fields inherited from interface BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
AbstractClassicTag()
           
 
Method Summary
protected  String applyNamingChain(String name)
          This method walks all of the naming chains and allows them to rewrite the name parameter.
protected  String getErrorsReport()
          This method will return a String that represents all of the errors that were registered for the tag.
protected  String getIdForTagId(String tagId)
          This method will generate a real id based upon the passed in tagId.
protected  List getNamingChain()
          Return an ArrayList which represents a chain of INameInterceptor objects.
protected  int getNextId(ServletRequest req)
          This method will generate the next unique int within the HTML tag.
protected  IScriptReporter getScriptReporter()
          Return the closest ScriptReporter in the parental chain.
abstract  String getTagName()
          Return the name of the tag.
protected  Locale getUserLocale()
          This method will return the user local of the request.
protected  boolean hasErrors()
          This method will return true if there have been any errors registered on this tag.
protected  void localRelease()
          This is a method that will reinitialize all temporary state on a tag and should be called in the doEndTag method.
protected  String qualifyAttribute(String name)
          An internal method that allows a tag to qualify the name paramater by converting it from a struts style naming convention to an explicit databinding expression.
 void registerTagError(AbstractPageError error)
          This will report an error from a tag.
 void registerTagError(String message, Throwable e)
          This will report an error from a tag.
protected  int reportAndExit(int returnValue)
          This is a simple routine which will call the error reporter if there is an error and then call local release before returning the returnValue.
protected  void reportErrors()
          This method will write out the String returned by getErrorsReport to the response output stream.
protected  String rewriteName(String name)
          This method will rewrite the name (id) by passing it to the URL Rewritter and getting back a value.
protected  String setNonEmptyValueAttribute(String attrValue)
          Filter out the empty string value and return either the value or null.
protected  String setRequiredValueAttribute(String attrValue, String attrName)
          Report an error if the value of attrValue is equal to the empty string, otherwise return that value.
protected  void write(String string)
          This mehod will write the passed string to the response.
 
Methods inherited from class BodyTagSupport
doAfterBody, doEndTag, doInitBody, doStartTag, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods inherited from class TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Tag
getParent, setPageContext, setParent
 

Field Detail

DefaultNamingChain

public static final List DefaultNamingChain
This List represents the default naming chain for handling dataSource attributes. The list is a read-only list which may be used by any dataSource implementation.


NETUI_UNIQUE_CNT

public static final String NETUI_UNIQUE_CNT
This is the name of a request scoped attribute which creates a unique id for processing a request.

See Also:
Constant Field Values

EMPTY_STRING

protected static final String EMPTY_STRING
String constant for the empty string.

See Also:
Constant Field Values
Constructor Detail

AbstractClassicTag

public AbstractClassicTag()
Method Detail

getTagName

public abstract String getTagName()
Return the name of the tag. Used by error reporting to get the name of the tag.

Specified by:
getTagName in interface INetuiTag
Returns:
the name of the tag.

localRelease

protected void localRelease()
This is a method that will reinitialize all temporary state on a tag and should be called in the doEndTag method.


getUserLocale

protected Locale getUserLocale()
This method will return the user local of the request.

Returns:
the Locale object to use when rendering this tag

write

protected final void write(String string)
This mehod will write the passed string to the response.

Parameters:
string - to be written to the response.

getNamingChain

protected List getNamingChain()
Return an ArrayList which represents a chain of INameInterceptor objects. This method by default returns null and should be overridden by objects that support naming.

Returns:
an ArrayList that will contain INameInterceptor objects.

applyNamingChain

protected String applyNamingChain(String name)
                           throws JspException
This method walks all of the naming chains and allows them to rewrite the name parameter. After the naming chain processes the name, it will be passed to rewriteName for final processing. If the naming chaing returned from getNamingChain returns null, the name will be passed to rewriteName and returned. If there is an ExpressionEvaluationException thrown by a INameInterceptor, the error will be registered with the tag and null will be returned.

Parameters:
name - the name to rewrite
Returns:
the name after it was passed to all INameInterceptors in the naming chain.
Throws:
JspException
See Also:
rewriteName(java.lang.String), INameInterceptor

qualifyAttribute

protected String qualifyAttribute(String name)
                           throws JspException
An internal method that allows a tag to qualify the name paramater by converting it from a struts style naming convention to an explicit databinding expression. The qualified name will be returned. This method may report an error if there is an error in the expression.

Parameters:
name - the name to be qualified
Returns:
the name which has been qualified
Throws:
JspException - throws a JspException if in-page error reporting is turned off.
See Also:
FormDataNameInterceptor

rewriteName

protected final String rewriteName(String name)
This method will rewrite the name (id) by passing it to the URL Rewritter and getting back a value.

Parameters:
name - the name that will be rewritten
Returns:
a name that has been rewritten by the URLRewriterService.

getIdForTagId

protected final String getIdForTagId(String tagId)
This method will generate a real id based upon the passed in tagId. The generated id will be constucted by searching upward for all the script containers that have a scope id set. These will form a fully qualified id.

Parameters:
tagId - The base tagId set on a tag
Returns:
an id value formed by considering all of the scope id's found in the tag hierarchy.

setRequiredValueAttribute

protected final String setRequiredValueAttribute(String attrValue,
                                                 String attrName)
                                          throws JspException
Report an error if the value of attrValue is equal to the empty string, otherwise return that value. If attrValue is equal to the empty string, an error is registered and null is returned.

Parameters:
attrValue - The value to be checked for the empty string
attrName - The name of the attribute
Returns:
either the attrValue if it is not the empty string or null
Throws:
JspException - A JspException will be thrown if inline error reporting is turned off.

setNonEmptyValueAttribute

protected final String setNonEmptyValueAttribute(String attrValue)
Filter out the empty string value and return either the value or null. When the value of attrValue is equal to the empty string this will return null, otherwise it will return the value of attrValue.

Parameters:
attrValue - This is the value we will check for the empty string.
Returns:
either the value of attrValue or null

reportAndExit

protected int reportAndExit(int returnValue)
                     throws JspException
This is a simple routine which will call the error reporter if there is an error and then call local release before returning the returnValue. This is a very common code sequence in the Classic Tags so we provide this routine.

Parameters:
returnValue - The value that will be returned.
Returns:
returnValue is always returned.
Throws:
JspException

registerTagError

public void registerTagError(String message,
                             Throwable e)
                      throws JspException
This will report an error from a tag. The error will contain a message. If error reporting is turned off, the message will be returned and the caller should throw a JspException to report the error.

Specified by:
registerTagError in interface INetuiTag
Parameters:
message - - the message to register with the error
Throws:
JspException - - if in-page error reporting is turned off this method will always throw a JspException.

registerTagError

public void registerTagError(AbstractPageError error)
                      throws JspException
This will report an error from a tag. The error must be be an AbstractPageError.

Specified by:
registerTagError in interface INetuiTag
Parameters:
error - The AbstractPageError to add to the error list.
Throws:
JspException - - if in-page error reporting is turned off this method will always throw a JspException.

hasErrors

protected boolean hasErrors()
This method will return true if there have been any errors registered on this tag. Otherwise it returns false

Returns:
true if errors have been reported on this tag.

reportErrors

protected void reportErrors()
                     throws JspException
This method will write out the String returned by getErrorsReport to the response output stream.

Throws:
JspException - if write throws an exception.
See Also:
write(java.lang.String)

getErrorsReport

protected String getErrorsReport()
This method will return a String that represents all of the errors that were registered for the tag. This method assumes that there are errors in the tag and asserts this is true. Code will typically call hasErrors before calling this method.

Returns:
A String that contains all of the errors registered on this tag.

getScriptReporter

protected IScriptReporter getScriptReporter()
Return the closest ScriptReporter in the parental chain. Searching starts at this node an moves upward through the parental chain.

Returns:
a ScriptReporter or null if there is not one found.

getNextId

protected int getNextId(ServletRequest req)
This method will generate the next unique int within the HTML tag.

Parameters:
req - the Request
Returns:
the next unique integer for this request.