Package net.sf.basedb.clients.web.taglib
Class StylableTag
- java.lang.Object
-
- javax.servlet.jsp.tagext.TagSupport
-
- net.sf.basedb.clients.web.taglib.StylableTag
-
- All Implemented Interfaces:
Serializable
,DynamicAttributes
,IterationTag
,JspTag
,Tag
,DynamicActionAttributes
- Direct Known Subclasses:
Body
,Button
,Button
,ButtonGroup
,ColumnDef
,ColumnSubtitles
,Data
,Form
,Header
,HeaderRow
,Headers
,Help
,HideableSection
,Icon
,Input
,Label
,Menu
,Menuitem
,Menuseparator
,Navigator
,Panel
,Path
,PathElement
,PresetSelector
,Row
,Rows
,Select
,Submenu
,TabControl
,Table
,Toolbar
,Zoom
public abstract class StylableTag extends TagSupport implements DynamicAttributes, DynamicActionAttributes
Generic tag class for tags that want to support id, class and style of the main html object they use. The class can be specified as a main class and a subclass which is added instead of replacing the main class.- Since:
- 3.1
- Author:
- Nicklas
- See Also:
- Serialized Form
- Last modified
- $Date: 2014-10-22 18:41:55 +0200 (on, 22 okt 2014) $
-
-
Field Summary
Fields Modifier and Type Field Description private String
clazz
private Map<String,DynamicActionAttribute>
dynamicAttributes
private static long
serialVersionUID
private String
style
private String
subclass
-
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
-
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
-
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
StylableTag(String defaultClass)
Create a new stylable tag.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addDynamicAttributes(StringBuilder sb)
protected void
addIdAndStyles(StringBuilder sb, String... extraClasses)
Add id, class and style attributes the the stringbuilder.String
getClazz()
Iterator<DynamicActionAttribute>
getDynamicActionAttributes()
Get an iterator that return all dynamic attributes.protected DynamicActionAttribute
getDynamicAttribute(String name)
Get the dynamic attribute for the given nameString
getFullClass(String... extraClasses)
Get the full class (eg. main and subclass) as a single string.protected String
getIdPrefix()
Optional prefix to include in the 'id' attribute.String
getStyle()
String
getSubclass()
protected void
initDefaultAttributes()
Initialize default attributes.void
setClazz(String clazz)
void
setDynamicAttribute(String uri, String name, Object value)
protected void
setMoreDynamicAttributes(Iterator<DynamicActionAttribute> moreAttributes)
void
setPageContext(PageContext pageContext)
Reset the dynamic attributes to make sure old ones are not included in case the tag object is reused.void
setStyle(String style)
void
setSubclass(String subclass)
-
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, doEndTag, doStartTag, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setParent, setValue
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
clazz
private String clazz
-
subclass
private String subclass
-
style
private String style
-
dynamicAttributes
private Map<String,DynamicActionAttribute> dynamicAttributes
-
-
Constructor Detail
-
StylableTag
protected StylableTag(String defaultClass)
Create a new stylable tag.- Parameters:
defaultClass
- The default class to use if the tag doesn't override with it's own value
-
-
Method Detail
-
setPageContext
public void setPageContext(PageContext pageContext)
Reset the dynamic attributes to make sure old ones are not included in case the tag object is reused.- Specified by:
setPageContext
in interfaceTag
- Overrides:
setPageContext
in classTagSupport
- Since:
- 3.3
-
initDefaultAttributes
protected void initDefaultAttributes()
Initialize default attributes. Can be called multiple times (once before each tag is used/re-used). This default implementation does nothing.- Since:
- 3.3.2
-
setClazz
public void setClazz(String clazz)
-
getClazz
public String getClazz()
-
setSubclass
public void setSubclass(String subclass)
-
getSubclass
public String getSubclass()
-
setStyle
public void setStyle(String style)
-
getStyle
public String getStyle()
-
setDynamicAttribute
public void setDynamicAttribute(String uri, String name, Object value)
- Specified by:
setDynamicAttribute
in interfaceDynamicAttributes
-
getDynamicActionAttributes
public Iterator<DynamicActionAttribute> getDynamicActionAttributes()
Description copied from interface:DynamicActionAttributes
Get an iterator that return all dynamic attributes. If no dynamic attributes have been defined, the method may return null or an iterator that doesn't return any elements.- Specified by:
getDynamicActionAttributes
in interfaceDynamicActionAttributes
- Returns:
- An iterator or null
-
getFullClass
public String getFullClass(String... extraClasses)
Get the full class (eg. main and subclass) as a single string.- Parameters:
extraClasses
- Additional classes that should also be added- Returns:
- The combined class or null if no class has been set
-
getIdPrefix
protected String getIdPrefix()
Optional prefix to include in the 'id' attribute. SeeaddIdAndStyles(StringBuilder, String...)
.- Returns:
- The default implementation return an empty string
- Since:
- 3.3
-
getDynamicAttribute
protected DynamicActionAttribute getDynamicAttribute(String name)
Get the dynamic attribute for the given name- Parameters:
name
- The name of the attribute- Returns:
- A DynamicActionAttribute object or null if no attribute with that name has been set
-
addIdAndStyles
protected void addIdAndStyles(StringBuilder sb, String... extraClasses)
Add id, class and style attributes the the stringbuilder.
-
setMoreDynamicAttributes
protected void setMoreDynamicAttributes(Iterator<DynamicActionAttribute> moreAttributes)
-
addDynamicAttributes
protected void addDynamicAttributes(StringBuilder sb)
-
-