public class CenterTag extends TagSupport
By using optional attributes, it can also position the element against the left or right border and can provide the material with a class that can be referenced by the CSS style sheet.
Modifier and Type | Field and Description |
---|---|
protected String |
align
Value of the attribute
align for the
custom tag. |
protected String |
className
Value of the attribute
className for the
custom tag. |
protected String |
style
Value of the attribute
style for the
custom tag. |
id, pageContext
EVAL_BODY_AGAIN
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
Constructor and Description |
---|
CenterTag() |
Modifier and Type | Method and Description |
---|---|
int |
doEndTag()
Writes test for the JSP when the closing tag for the custom
tag is encountered.
|
int |
doStartTag()
Writes text for the JSP (Java Server Page) when the opening tag
of the custom tag is encountered.
|
String |
getAlign()
Returns the value of the attribute
align for the
custom tag. |
String |
getClassName()
Returns the value of the attribute
className
for the custom tag. |
protected String |
getStyle()
Returns the value of the attribute
style
for the custom tag. |
void |
setAlign(String value)
Used by the servlet generated by the application server to
set the value of the attribute
align
for the custom tag. |
void |
setClassName(String value)
Used by the application server to set the
value of the variable className when it is
encountered as an attribute in the custom tags.
|
void |
setPageContext(PageContext context) |
protected void |
setStyle(String value)
Used by the application server to set the
value of the variable
style when it is
encountered as an attribute in the
custom tags. |
doAfterBody, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setParent, setValue
protected String className
className
for the
custom tag.
When the tag is translated into a scriptlet, this
attribute becomes the value of the class
attribute for a div
element. However,
class is a reserved word in Java, requiring the use
of a different name for the attribute.
public CenterTag()
public void setAlign(String value)
align
for the custom tag.
The name of the attribute is passed to the application server in the TLD file so that the application server can use the name of the attribute to write function calls with the correct class names.
value
- Value to be used for attribute alignalign
public String getAlign()
align
for the
custom tag.align
public void setClassName(String value)
value
- Value to be used for attribute classNameclassName
public String getClassName()
className
for the custom tag.className
protected void setStyle(String value)
style
when it is
encountered as an attribute in the
custom tags.value
- Value to be used for attribute stylestyle
protected String getStyle()
style
for the custom tag.style
public void setPageContext(PageContext context)
setPageContext
in interface Tag
setPageContext
in class TagSupport
public int doStartTag() throws JspException
The block of text is surrounded by a table since a table's width will automatically shrink if the sum of the column widths is less that the available width. Setting margin-left and margin-right to auto causes the table to be centered in this situation.
The method returns Tag.EVAL_BODY_INCLUDE
to indicate that
the material in the body of the tag will be processed by the
JSP preprocessor.
doStartTag
in interface Tag
doStartTag
in class TagSupport
JspException
public int doEndTag() throws JspException
The method returns Tag.EVAL_PAGE
to indicate
that processing of the Java Server Page should continue.
doEndTag
in interface Tag
doEndTag
in class TagSupport
JspException