org.loom.tags
Class AbstractTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.SimpleTagSupport
      extended by org.loom.tags.AbstractTag
All Implemented Interfaces:
javax.servlet.jsp.tagext.DynamicAttributes, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.SimpleTag, LoomTag
Direct Known Subclasses:
AbstractDecoratedTag, AbstractFormatTag, AbstractOutTag, AbstractPagedContainerTag, AbstractWebResourceTag, CacheTag, ColumnTag, ErrorTag, FooterTag, InputHiddenTag, LinkTag, MenuItemTag, MessagesTag, OptionTag, ParamTag, RedirectTag

public abstract class AbstractTag
extends javax.servlet.jsp.tagext.SimpleTagSupport
implements LoomTag, javax.servlet.jsp.tagext.DynamicAttributes

Parent of any Loom tag


Field Summary
protected  ExpressionLanguageProxy expressionLanguageProxy
           
protected  LoomServletRequestFactory loomServletRequestFactory
           
protected  WriterWrapper<?> out
          the WriterWrapper instance
protected  MessagesRepository repository
          the MessagesRepository instance
protected  LoomServletRequest request
          the request instance that is being served
protected  LoomServletResponse response
          the response instance that is being written
 
Constructor Summary
AbstractTag()
           
 
Method Summary
protected  WriterWrapper<?> createWriterWrapper()
           
protected  boolean doBody()
          Invokes a tag body
protected  java.lang.String doBufferedBody()
          Invokes a tag body using a StringBuffer, to delay its output
 void doTag()
          Initializes the Request and PageData properties, and forward the call to the child class
abstract  void doTagImpl()
          The method that must be implemented by the child class
protected  void endTag()
          Does the tag cleanup, if any.
 java.lang.Object evaluateExpression(java.lang.String expression)
           
protected  java.lang.Object getActionProperty(java.lang.String propertyName)
           
protected
<T> T
getAncestorWithClass(java.lang.Class<T> clazz)
          Find a containing ancestor with the required class.
protected  StringWriterWrapper getBufferedBody()
           
 TagAttributes getExtendedAttributes()
           
 MessagesRepository getMessagesRepository()
           
 javax.servlet.jsp.PageContext getPageContext()
           
 LoomServletRequest getRequest()
           
 LoomServletResponse getResponse()
           
 java.lang.Object getScopedAttribute(java.lang.String name, Scope scope)
          Get a scoped var
 WriterWrapper<?> getWriter()
           
protected  void initTag()
          Initializes the tag attributes
protected  void printParentAttributes()
          Print the extended attributes
 void removeScopedAttribute(java.lang.String name, Scope scope)
          Remove a scoped attribute
 void setDynamicAttribute(java.lang.String uri, java.lang.String localName, java.lang.Object value)
          Admit extra attributes like: data-* attributes: These will get appended as extendedAttributes, for further use by javascript code param-* attributes: If the tag implements ParameterContainer, these attributes can be used as a replacement for l:param
 void setExtendedAttribute(java.lang.String name, java.lang.Object value)
          Add an attribute not suported by the HTML 5 spec
 void setJspContext(javax.servlet.jsp.JspContext pc)
          Eager initialization that should be done before any other parameter gets assigned.
 void setRequest(LoomServletRequest request)
           
 void setResponse(LoomServletResponse response)
           
 void setScopedAttribute(java.lang.String name, java.lang.Object value, Scope scope)
          Create a scoped attribute
 void setWriter(WriterWrapper<?> out)
           
 
Methods inherited from class javax.servlet.jsp.tagext.SimpleTagSupport
findAncestorWithClass, getJspBody, getJspContext, getParent, setJspBody, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loomServletRequestFactory

@Inject
protected LoomServletRequestFactory loomServletRequestFactory

expressionLanguageProxy

@Inject
protected ExpressionLanguageProxy expressionLanguageProxy

request

protected LoomServletRequest request
the request instance that is being served


response

protected LoomServletResponse response
the response instance that is being written


repository

protected MessagesRepository repository
the MessagesRepository instance


out

protected WriterWrapper<?> out
the WriterWrapper instance

Constructor Detail

AbstractTag

public AbstractTag()
Method Detail

setJspContext

public void setJspContext(javax.servlet.jsp.JspContext pc)
Eager initialization that should be done before any other parameter gets assigned. Specifically this method initializes the request and response Objects

Specified by:
setJspContext in interface javax.servlet.jsp.tagext.SimpleTag
Overrides:
setJspContext in class javax.servlet.jsp.tagext.SimpleTagSupport

initTag

protected void initTag()
Initializes the tag attributes


getAncestorWithClass

protected <T> T getAncestorWithClass(java.lang.Class<T> clazz)
Find a containing ancestor with the required class. If not found, throws IllegalArgumentException


endTag

protected void endTag()
Does the tag cleanup, if any.


doTag

public void doTag()
           throws javax.servlet.jsp.JspException,
                  java.io.IOException
Initializes the Request and PageData properties, and forward the call to the child class

Specified by:
doTag in interface javax.servlet.jsp.tagext.SimpleTag
Overrides:
doTag in class javax.servlet.jsp.tagext.SimpleTagSupport
Throws:
javax.servlet.jsp.JspException
java.io.IOException

doTagImpl

public abstract void doTagImpl()
                        throws javax.servlet.jsp.JspException,
                               java.io.IOException
The method that must be implemented by the child class

Throws:
javax.servlet.jsp.JspException
java.io.IOException

createWriterWrapper

protected WriterWrapper<?> createWriterWrapper()

getPageContext

public javax.servlet.jsp.PageContext getPageContext()

doBufferedBody

protected java.lang.String doBufferedBody()
                                   throws javax.servlet.jsp.JspException,
                                          java.io.IOException
Invokes a tag body using a StringBuffer, to delay its output

Throws:
javax.servlet.jsp.JspException
java.io.IOException

doBody

protected boolean doBody()
                  throws javax.servlet.jsp.JspException,
                         java.io.IOException
Invokes a tag body

Returns:
true if there was a body, false if not
Throws:
javax.servlet.jsp.JspException
java.io.IOException

setScopedAttribute

public void setScopedAttribute(java.lang.String name,
                               java.lang.Object value,
                               Scope scope)
Create a scoped attribute

Specified by:
setScopedAttribute in interface LoomTag
Parameters:
name - the attribute name
value - the value
scope - the scope of the attribute. Cannot be null.

removeScopedAttribute

public void removeScopedAttribute(java.lang.String name,
                                  Scope scope)
Remove a scoped attribute

Parameters:
name - the var name
scope - the scope of the attribute. Cannot be null.

getScopedAttribute

public java.lang.Object getScopedAttribute(java.lang.String name,
                                           Scope scope)
Get a scoped var

Specified by:
getScopedAttribute in interface LoomTag
Parameters:
name - the var name
scope - the scope of the var. If null checks them all

getActionProperty

protected java.lang.Object getActionProperty(java.lang.String propertyName)
Returns:
the value of an action property or null if there is no parsed action

setExtendedAttribute

public void setExtendedAttribute(java.lang.String name,
                                 java.lang.Object value)
Add an attribute not suported by the HTML 5 spec

Specified by:
setExtendedAttribute in interface LoomTag
Parameters:
name - the name of the attribute
value - the value of the attribute

evaluateExpression

public java.lang.Object evaluateExpression(java.lang.String expression)
                                    throws javax.servlet.jsp.JspException
Parameters:
expression - the expression to be evaluated, such as ${something} + ${orTheOther}
Returns:
the evaluated response
Throws:
javax.servlet.jsp.JspException

printParentAttributes

protected void printParentAttributes()
                              throws java.io.IOException,
                                     javax.servlet.jsp.JspException
Print the extended attributes

Throws:
java.io.IOException
javax.servlet.jsp.JspException

setRequest

public void setRequest(LoomServletRequest request)

setDynamicAttribute

public void setDynamicAttribute(java.lang.String uri,
                                java.lang.String localName,
                                java.lang.Object value)
                         throws javax.servlet.jsp.JspException
Admit extra attributes like:

Specified by:
setDynamicAttribute in interface javax.servlet.jsp.tagext.DynamicAttributes
Throws:
javax.servlet.jsp.JspException

getRequest

public LoomServletRequest getRequest()
Specified by:
getRequest in interface LoomTag
Returns:
the current request object

getResponse

public LoomServletResponse getResponse()

getWriter

public WriterWrapper<?> getWriter()

setWriter

public void setWriter(WriterWrapper<?> out)

getMessagesRepository

public MessagesRepository getMessagesRepository()

getExtendedAttributes

public TagAttributes getExtendedAttributes()
Specified by:
getExtendedAttributes in interface LoomTag
Returns:
the TagAttributes instance with the extended (not included in the HTML 5 spec) attributes of this link

setResponse

public void setResponse(LoomServletResponse response)

getBufferedBody

protected StringWriterWrapper getBufferedBody()