|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.bebop.Completable
com.arsdigita.bebop.SimpleComponent
com.arsdigita.bebop.TextStylable
com.arsdigita.bebop.BlockStylable
com.arsdigita.bebop.form.Widget
A class representing a widget in the graphical representation of a form.
A widget may correspond to a standard HTML form element, or to a more specific element or set of elements, such as a date widget that allows input of month, day and year (and possibly time as well).
This class and its subclasses provide methods to set all element
attributes except for VALUE
, which is typically
dependent on the request. At the time of a request, a widget
object merges a dynamically specified value or set of values with
its own set of persistent attributes to render the final HTML for
the widget. Other dynamic attributes may be associated with the
form component via a WidgetPeer
associated with the
widget.
Nested Class Summary | |
static interface |
Widget.ValidationGuard
Inner interface used to determine if the validation listeners should be run for this widget or not. |
Field Summary | |
static String |
versionId
|
Fields inherited from class com.arsdigita.bebop.BlockStylable |
ABSBOTTOM, ABSMIDDLE, BASELINE, BOTTOM, CENTER, FULL_WIDTH, INSERT, LEFT, MIDDLE, RIGHT, TEXTTOP, TOP |
Fields inherited from class com.arsdigita.bebop.SimpleComponent |
m_attr |
Fields inherited from interface com.arsdigita.bebop.util.BebopConstants |
BEBOP_BORDER, BEBOP_BOXPANEL, BEBOP_CELL, BEBOP_CHECKBOX, BEBOP_CHECKBOXGROUP, BEBOP_COLUMNPANEL, BEBOP_DATE, BEBOP_DATETIME, BEBOP_DHTMLEDITOR, BEBOP_FORMERRORS, BEBOP_FORMWIDGET, BEBOP_GRIDPANEL, BEBOP_LIST, BEBOP_MULTISELECT, BEBOP_OPTION, BEBOP_PAD, BEBOP_PADFRAME, BEBOP_PANELROW, BEBOP_PORTAL, BEBOP_PORTLET, BEBOP_RADIO, BEBOP_RADIOGROUP, BEBOP_SEG_BODY, BEBOP_SEG_HEADER, BEBOP_SEG_PANEL, BEBOP_SEGMENT, BEBOP_SELECT, BEBOP_TABLE, BEBOP_TABLEBODY, BEBOP_TABLEROW, BEBOP_TEXTAREA |
Fields inherited from interface com.arsdigita.bebop.Component |
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE |
Constructor Summary | |
protected |
Widget(ParameterModel model)
Constructs a new widget. |
protected |
Widget(String name)
Constructs a new widget. |
Method Summary | |
void |
addError(GlobalizedMessage mesg)
Adds an error to be displayed with this parameter. |
void |
addError(String error)
Adds an error to be displayed with this parameter. |
void |
addPrintListener(PrintListener listener)
Adds a print listener for this widget. |
void |
addValidationListener(ParameterListener listener)
|
Object |
clone()
Clones a component. |
protected ParameterListener |
createParameterListener()
|
protected Widget |
firePrintEvent(PageState state)
|
protected void |
fireValidation(ParameterEvent evt)
|
protected void |
generateErrors(PageState state,
Element parent)
Generates the XML for the given widget |
protected void |
generateWidget(PageState state,
Element parent)
Generates the DOM for the given widget |
void |
generateXML(PageState state,
Element parent)
This method creates the DOM for the widget. |
String |
getDefaultValue()
Gets the default value in the parameter model for this element. |
protected String |
getElementTag()
The XML tag. |
protected Iterator |
getErrors(PageState ps)
|
Form |
getForm()
Gets the Form Object for this Widget. |
String |
getName()
|
protected ParameterData |
getParameterData(PageState ps)
|
ParameterModel |
getParameterModel()
Allows access to underlying parameterModel. |
protected abstract String |
getType()
Returns a string naming the type of this widget. |
Object |
getValue(PageState ps)
Get the value associated with this widget in the request described by ps . |
abstract boolean |
isCompound()
Returns true if the widget consists of multiple HTML elements. |
boolean |
isPassIn()
The "pass in" property determines whether the value for this parameter is generally passed in from the outside. |
void |
register(Form form,
FormModel model)
Registers the ParameterModel of this Widget with the containing Form. |
void |
removePrintListener(PrintListener listener)
Remove a previously added print listener. |
void |
removeValidationListener(ParameterListener listener)
|
void |
respond(PageState state)
Respond to an incoming request by calling respond on the
form to which the widget belongs. |
void |
setDefaultValue(Object value)
Sets the default value in the parameter model for this element. |
void |
setDisabled()
Marks this widget as disabled, which has the effect of preventing the widget's value being submitted with the form, and will typically cause the widget to be 'grayed out' on the form. |
void |
setForm(Form form)
Sets the Form Object for this Widget. |
void |
setHint(String hint)
Sets a popup hint for the widget |
void |
setOnBlur(String javascriptCode)
Sets the ONBLUR attribute for the HTML tags that compose this element. |
void |
setOnChange(String javascriptCode)
Sets the ONCHANGE attribute for the HTML tags that compose this element. |
void |
setOnFocus(String javascriptCode)
Sets the ONFOCUS attribute for the HTML tags that compose this element. |
void |
setOnKeyUp(String javascriptCode)
Sets the ON_KEY_UP attribute for the HTML tags that compose this element. |
void |
setOnSelect(String javascriptCode)
Sets the ONSELECT attribute for the HTML tags that compose this element. |
void |
setParameterModel(ParameterModel parameterModel)
The ParameterModel is normally set via the constructors. |
void |
setPassIn(boolean v)
Set whether this parameter should be treated as a "pass in" parameter. |
void |
setPrintListener(PrintListener listener)
Set the print listener for this widget. |
void |
setReadOnly()
Marks this widget as readonly, which has the effect of preventing the user from modifying the widget's contents. |
void |
setValidateInvisible(boolean value)
|
void |
setValidationGuard(Widget.ValidationGuard guard)
Specify a Widget.ValidationGuard implementation to use to determine if this widget should run its validation listeners. |
void |
setValue(PageState ps,
Object value)
Set the value of the parameter associated with this widget to a new value. |
String |
toString()
|
boolean |
validateInvisible()
|
Methods inherited from class com.arsdigita.bebop.BlockStylable |
setBorder, setBorder, setBorderColor, setHorizontalAlignment, setMargin, setMargin, setPadding, setPadding, setVerticalAlignment |
Methods inherited from class com.arsdigita.bebop.TextStylable |
setBackgroundColor, setColor |
Methods inherited from class com.arsdigita.bebop.SimpleComponent |
children, exportAttributes, getAttribute, getClassAttr, getIdAttr, getKey, getMetaDataAttribute, getStyleAttr, hasAttributes, isLocked, isVisible, lock, register, setAttribute, setClassAttr, setIdAttr, setKey, setMetaDataAttribute, setStyleAttr, setVisible |
Methods inherited from class com.arsdigita.bebop.Completable |
addCompletionListener, fireCompletionEvent |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String versionId
Constructor Detail |
protected Widget(String name)
protected Widget(ParameterModel model)
Each new widget is associated with a ParameterModel describing the data object(s) submitted from the widget.
Method Detail |
public abstract boolean isCompound()
protected abstract String getType()
protected ParameterListener createParameterListener()
public void setValidateInvisible(boolean value)
public boolean validateInvisible()
protected void fireValidation(ParameterEvent evt) throws FormProcessException
FormProcessException
public void addValidationListener(ParameterListener listener)
public void removeValidationListener(ParameterListener listener)
public void addPrintListener(PrintListener listener) throws TooManyListenersException, IllegalArgumentException
PrintListener
is expected to
modify the target of the PrintEvent
.
listener
- the print listener
IlegalArgumentException
- listener
is null
TooManyListenersException
- a print listener has previously been
added
IllegalArgumentException
public void setPrintListener(PrintListener listener) throws IllegalArgumentException
listener
- the print listener
IlegalArgumentException
- listener
is null
IllegalArgumentException
public void removePrintListener(PrintListener listener) throws IllegalArgumentException
listener
is
not the listener that has been added with addPrintListener
, an IllegalArgumentException will be thrown.
listener
- the listener that had been added with
addPrintListener
IllegalArgumentException
- listener
is not the
currently registered print listener or is null
.public void register(Form form, FormModel model)
register
in interface Component
register
in class SimpleComponent
public void setForm(Form form)
form
- The Form
Object for this Widget
IllegalStateException
- if form already set.public Form getForm() throws RuntimeException
Form
Object for this Widget.
RuntimeException
public void setOnFocus(String javascriptCode)
public void setOnBlur(String javascriptCode)
public void setOnSelect(String javascriptCode)
public void setOnChange(String javascriptCode)
public void setOnKeyUp(String javascriptCode)
public void setDefaultValue(Object value)
public void setReadOnly()
public void setDisabled()
public void setHint(String hint)
public String getDefaultValue()
public String getName()
public final boolean isPassIn()
true
, the model always tries to get the parameter
value from the request, no matter whether the request is the initial
request or a submission of the form to which the widget belongs.
If this property is false
, the parameter value is
only read from the request if it is a submission of the form
containing the widget.
By default, this property is false
.
true
if an attempt should always be made to
retrieve the parameter value from the request.public final void setPassIn(boolean v)
v
- true
if this parameter is a pass in parameter.isPassIn()
public final void setParameterModel(ParameterModel parameterModel)
public final ParameterModel getParameterModel()
public void generateXML(PageState state, Element parent)
This method creates the DOM for the widget. The method is called by the Bebop framework and should not be invoked by application developers.
The method first fires the print event allowing application developers to set certain properties of the Widget at request time in a PrintListener. The methods generateWidget and generateErrors will then be invoked to generate either of the following
<bebop:formErrors message=...>
</bebop:formErrors>
<bebop:formWidget name=... type=... value=... [onXXX=...]>
</bebop:formWidget>
generateXML
in interface Component
generateXML
in class SimpleComponent
protected Widget firePrintEvent(PageState state)
protected String getElementTag()
protected void generateWidget(PageState state, Element parent)
Generates DOM fragment:
<bebop:formWidget name=... type=... value=... [onXXX=...]>
</bebop:formWidget>
protected void generateErrors(PageState state, Element parent)
Generates XML fragment:
<bebop:formErrors message=... id=name>
</bebop:formErrors>
public Object getValue(PageState ps)
ps
. The type of the returned object depends on the
ParameterModel
underlying this widget. This method is
typically called in a FormProcessListener to access the value that was
submitted for a Widget in the Form.
ps
- describes the request currently being processedpublic void setValue(PageState ps, Object value) throws IllegalStateException
value
depends on the
ParameterModel
underlying the widget. This method is
typically called in a FormInitListener to initialize the value of
a Widget in the Form at request time.
IllegalStateExeption
- the form to which the widget belongs has
not been processed yet.
IllegalStateException
protected Iterator getErrors(PageState ps)
protected ParameterData getParameterData(PageState ps)
public void respond(PageState state) throws javax.servlet.ServletException
respond
on the
form to which the widget belongs. This method is called
by the Bebop framework and should not be invoked by application
developers. It is somewhat questionable that
this method should ever be called, rather than having Form.respond()
called directly.
respond
in interface Component
respond
in class SimpleComponent
state
- the current page state
javax.servlet.ServletException
public Object clone() throws CloneNotSupportedException
SimpleComponent
clone
in class SimpleComponent
CloneNotSupportedException
public void setValidationGuard(Widget.ValidationGuard guard)
guard
- the Widget.ValidationGuard.public void addError(GlobalizedMessage mesg)
mesg
- A GlobalizedMessage that will resolve to the error for the user.public void addError(String error)
error
- A string showing the error to the user.public String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |