net.sourceforge.stripes.tag
Class DefaultTagErrorRenderer

java.lang.Object
  extended by net.sourceforge.stripes.tag.DefaultTagErrorRenderer
All Implemented Interfaces:
TagErrorRenderer

public class DefaultTagErrorRenderer
extends Object
implements TagErrorRenderer

This default implementation of the TagErrorRenderer interface sets the html class attribute to 'error'. More specifically, if the tag had no previous CSS class, it will have its class attribute set to error. If it previously had a CSS class attribute, e.g. class="foo", then it's class attribute will be re-written as class="foo error", which instructs the browser to apply both styles, with error taking precedence. The use of a single class name allows applications to define a single style for all input fields, and then override it for specific fields as they choose.

An example of the css definition to set backgrounds to yellow by default, but to red for checkboxes and radio buttons follows:

input.error { background-color: yellow; } input[type="checkbox"].error, input[type="radio"].error {background-color: red; }

Author:
Greg Hinkle, Tim Fennell

Constructor Summary
DefaultTagErrorRenderer()
           
 
Method Summary
 void doAfterEndTag()
          Resets the tag's class attribute to it's original value in case the tag gets pooled.
 void doBeforeStartTag()
          Ensures that the tag's list of CSS classes includes the "error" class.
protected  InputTagSupport getTag()
          Returns the tag which is being rendered.
 void init(InputTagSupport tag)
          Simply stores the tag passed in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTagErrorRenderer

public DefaultTagErrorRenderer()
Method Detail

init

public void init(InputTagSupport tag)
Simply stores the tag passed in.

Specified by:
init in interface TagErrorRenderer
Parameters:
tag - The InputTagSuppport subclass that will be modified

getTag

protected InputTagSupport getTag()
Returns the tag which is being rendered. Useful mostly when subclassing the default renderer to add further functionality.

Returns:
the input tag being rendered

doBeforeStartTag

public void doBeforeStartTag()
Ensures that the tag's list of CSS classes includes the "error" class.

Specified by:
doBeforeStartTag in interface TagErrorRenderer

doAfterEndTag

public void doAfterEndTag()
Resets the tag's class attribute to it's original value in case the tag gets pooled.

Specified by:
doAfterEndTag in interface TagErrorRenderer


? Copyright 2005-2006, Stripes Development Team.