org.riotfamily.forms
Class AbstractElement

java.lang.Object
  extended by org.riotfamily.forms.AbstractElement
All Implemented Interfaces:
Element
Direct Known Subclasses:
AbstractConditionalElement, AbstractEditorBase, AbstractResourceElement

public abstract class AbstractElement
extends Object
implements Element

Convenient superclass for element implementations.


Field Summary
protected  RiotLog log
           
 
Constructor Summary
AbstractElement()
           
 
Method Summary
protected  void afterFormContextSet()
           
protected  void afterFormSet()
           
 void focus()
          Focuses the element.
 String getEventTriggerId()
           
 Form getForm()
          Returns the form that contains the element.
 FormContext getFormContext()
          Returns the FormContext.
protected  FormListener getFormListener()
           
 String getHint()
           
 String getId()
          Returns the previously assigned id.
 String getLabel()
           
 Element getParent()
          Returns the element's parent.
 String getStyleClass()
          Returns the elements style class.
protected  String getSystemStyleClass()
           
protected  String getWrapperStyleClass()
           
 boolean isCompositeElement()
          Returns whether the element is composed of multiple widgets.
 boolean isEnabled()
          Returns true, if the element as well as its parent is enabled.
 boolean isRequired()
          Returns whether the element is mandatory and must be filled out by the user.
 boolean isVisible()
           
 void processRequest(FormRequest request)
          Subclasses may override this method to change their internal state according the given request.
 void render()
           
 void render(PrintWriter writer)
          Renders the element to the given writer.
protected abstract  void renderInternal(PrintWriter writer)
           
 void setEnabled(boolean enabled)
          Enables (or disables) the element.
 void setForm(Form form)
          Sets a reference to the form that contains the element.
 void setFormContext(FormContext formContext)
          Sets the FormContext.
 void setHint(String hint)
           
 void setId(String id)
          Sets the element's unique id.
protected  void setInline(boolean inline)
           
 void setLabel(String label)
           
 void setParent(Element parent)
          Sets the element's parent.
 void setReadOnly(boolean readOnly)
          Setting an element to read-only is the same as invoking setEnabled(false).
 void setRequired(boolean required)
          Sets whether the element is required.
 void setStyleClass(String styleClass)
           
 void setVisible(boolean visible)
           
protected  void setWrap(boolean wrap)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected RiotLog log
Constructor Detail

AbstractElement

public AbstractElement()
Method Detail

getId

public String getId()
Description copied from interface: Element
Returns the previously assigned id.

Specified by:
getId in interface Element

setId

public void setId(String id)
Description copied from interface: Element
Sets the element's unique id. Ids are assigned when an element is registered with a form.

Specified by:
setId in interface Element
See Also:
Form.registerElement(Element)

getEventTriggerId

public String getEventTriggerId()
Specified by:
getEventTriggerId in interface Element

getStyleClass

public String getStyleClass()
Description copied from interface: Element
Returns the elements style class.

Specified by:
getStyleClass in interface Element

setStyleClass

public void setStyleClass(String styleClass)

getSystemStyleClass

protected String getSystemStyleClass()

getWrapperStyleClass

protected String getWrapperStyleClass()

setWrap

protected void setWrap(boolean wrap)

setInline

protected void setInline(boolean inline)

getForm

public Form getForm()
Description copied from interface: Element
Returns the form that contains the element.

Specified by:
getForm in interface Element

setForm

public final void setForm(Form form)
Description copied from interface: Element
Sets a reference to the form that contains the element.

Specified by:
setForm in interface Element

afterFormSet

protected void afterFormSet()

getFormContext

public FormContext getFormContext()
Description copied from interface: Element
Returns the FormContext.

Specified by:
getFormContext in interface Element

setFormContext

public final void setFormContext(FormContext formContext)
Description copied from interface: Element
Sets the FormContext. Invoked by Form.registerElement(Element) or Form.setFormContext(FormContext).

Specified by:
setFormContext in interface Element

afterFormContextSet

protected void afterFormContextSet()

getParent

public Element getParent()
Description copied from interface: Element
Returns the element's parent.

Specified by:
getParent in interface Element

setParent

public void setParent(Element parent)
Description copied from interface: Element
Sets the element's parent. E.g. the parent element is taken into account to determine the enabled state of the element.

Specified by:
setParent in interface Element

getLabel

public String getLabel()

setLabel

public void setLabel(String label)

getHint

public String getHint()

setHint

public void setHint(String hint)

focus

public void focus()
Description copied from interface: Element
Focuses the element.

Specified by:
focus in interface Element

render

public final void render()

render

public final void render(PrintWriter writer)
Description copied from interface: Element
Renders the element to the given writer.

Specified by:
render in interface Element

renderInternal

protected abstract void renderInternal(PrintWriter writer)

processRequest

public void processRequest(FormRequest request)
Subclasses may override this method to change their internal state according the given request.

Specified by:
processRequest in interface Element

isEnabled

public final boolean isEnabled()
Returns true, if the element as well as its parent is enabled.

Specified by:
isEnabled in interface Element

setEnabled

public final void setEnabled(boolean enabled)
Enables (or disables) the element. The state of nested elements will be implicitly affected, since isEnabled() takes the state of its parent element into account.

Specified by:
setEnabled in interface Element

setReadOnly

public void setReadOnly(boolean readOnly)
Setting an element to read-only is the same as invoking setEnabled(false).


isRequired

public boolean isRequired()
Returns whether the element is mandatory and must be filled out by the user.

Specified by:
isRequired in interface Element

setRequired

public void setRequired(boolean required)
Sets whether the element is required.

Specified by:
setRequired in interface Element

isVisible

public boolean isVisible()
Specified by:
isVisible in interface Element

setVisible

public void setVisible(boolean visible)

isCompositeElement

public boolean isCompositeElement()
Description copied from interface: Element
Returns whether the element is composed of multiple widgets. The information may be used by templates to render composite elements in the same style as element groups or nested forms.

Specified by:
isCompositeElement in interface Element

getFormListener

protected FormListener getFormListener()