|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.cocoon.forms.formmodel.AbstractWidget org.apache.cocoon.forms.formmodel.Repeater
public class Repeater
A repeater is a widget that repeats a number of other widgets.
Technically, the Repeater widget is a ContainerWidget whose children are
Repeater.RepeaterRow
s, and the RepeaterRows in turn are ContainerWidgets
containing the actual repeated widgets. However, in practice, you won't need
to use the RepeaterRow widget directly.
Using the methods getSize()
and getWidget(int, java.lang.String)
you can access all of the repeated widget instances.
Nested Class Summary | |
---|---|
class |
Repeater.RepeaterRow
|
Field Summary | |
---|---|
protected RepeaterDefinition |
definition
|
protected List |
rows
|
protected ValidationError |
validationError
|
Fields inherited from class org.apache.cocoon.forms.formmodel.AbstractWidget |
---|
wasValid |
Fields inherited from interface org.apache.cocoon.forms.formmodel.Widget |
---|
PATH_SEPARATOR |
Constructor Summary | |
---|---|
Repeater(RepeaterDefinition repeaterDefinition)
|
Method Summary | |
---|---|
void |
addRepeaterListener(RepeaterListener listener)
|
Repeater.RepeaterRow |
addRow()
|
Repeater.RepeaterRow |
addRow(int index)
|
void |
broadcastEvent(WidgetEvent event)
Broadcast an event previously queued by this widget to its event listeners. |
void |
clear()
Clears all rows from the repeater and go back to the initial size |
void |
generateDisplayData(ContentHandler contentHandler)
Delegates to the AbstractWidget.getDefinition() of this widget to generate a common
set of 'display' data. |
void |
generateItemSaxFragment(ContentHandler contentHandler,
Locale locale)
Generates nested additional content nested inside the main element for this widget which is generated by AbstractWidget.generateSaxFragment(ContentHandler, Locale)
The implementation on the AbstractWidget level inserts no additional XML. |
void |
generateSize(ContentHandler contentHandler)
Generates a repeater-size element with a size attribute indicating the size of this repeater. |
void |
generateWidgetLabel(String widgetId,
ContentHandler contentHandler)
Generates the label of a certain widget in this repeater. |
Widget |
getChild(String id)
Overrides AbstractWidget.getChild(String) to return the
repeater-row indicated by the index in 'id' |
WidgetDefinition |
getDefinition()
Concrete subclasses should allow access to their underlaying Definition through this method. |
int |
getMaxSize()
|
int |
getMinSize()
|
static Repeater.RepeaterRow |
getParentRow(Widget widget)
Crawls up the parents of a widget up to finding a repeater row. |
Repeater.RepeaterRow |
getRow(int index)
|
int |
getSize()
|
ValidationError |
getValidationError()
Set a validation error on this field. |
Widget |
getWidget(int rowIndex,
String id)
Gets a widget on a certain row. |
AttributesImpl |
getXMLElementAttributes()
Adds @size attribute |
String |
getXMLElementName()
The XML element name used in AbstractWidget.generateSaxFragment(ContentHandler, Locale)
to produce the wrapping element for all the XML-instance-content of this Widget. |
boolean |
hasRepeaterListeners()
|
int |
indexOf(Repeater.RepeaterRow row)
Get the position of a row in this repeater. |
void |
initialize()
Called after widget's environment has been setup, to allow for any contextual initalization, such as looking up case widgets for union widgets. |
void |
moveRow(int from,
int to)
Move a row from one place to another |
void |
moveRow2(int from,
int to)
Move a row from one place to another. |
void |
moveRowLeft(int index)
|
void |
moveRowRight(int index)
|
void |
readFromRequest(FormContext formContext)
Lets this widget read its data from a request. |
void |
removeRepeaterListener(RepeaterListener listener)
|
void |
removeRow(int index)
|
void |
removeRows()
Deprecated. See clear() |
void |
setValidationError(ValidationError error)
set a validation error |
boolean |
validate()
Validates this widget and returns the outcome. |
Methods inherited from class org.apache.cocoon.forms.formmodel.AbstractWidget |
---|
addValidator, generateLabel, generateSaxFragment, getAttribute, getCombinedState, getForm, getFullName, getId, getLocation, getName, getParent, getRequestParameterName, getState, getValue, getWidget, isRequired, isValid, lookupWidget, removeAttribute, removeValidator, setAttribute, setParent, setState, setValue, toString, widgetNameChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final RepeaterDefinition definition
protected final List rows
protected ValidationError validationError
Constructor Detail |
---|
public Repeater(RepeaterDefinition repeaterDefinition)
Method Detail |
---|
public WidgetDefinition getDefinition()
AbstractWidget
null
they should also organize
own implementations of AbstractWidget.getId()
, AbstractWidget.getLocation()
,
AbstractWidget.validate()
, AbstractWidget.generateLabel(ContentHandler)
and
AbstractWidget.generateDisplayData(ContentHandler)
to avoid NPE's.
getDefinition
in interface Widget
getDefinition
in class AbstractWidget
WidgetDefinition.createInstance()
)public void initialize()
AbstractWidget
initialize
in interface Widget
initialize
in class AbstractWidget
public int getSize()
public int getMinSize()
public int getMaxSize()
public Repeater.RepeaterRow addRow()
public Repeater.RepeaterRow addRow(int index)
public Repeater.RepeaterRow getRow(int index)
public Widget getChild(String id)
AbstractWidget.getChild(String)
to return the
repeater-row indicated by the index in 'id'
getChild
in class AbstractWidget
id
- index of the row as a string-id
public static Repeater.RepeaterRow getParentRow(Widget widget)
widget
- the widget whose row is to be found
public int indexOf(Repeater.RepeaterRow row)
row
- the row which we search the index for
public void removeRow(int index)
IndexOutOfBoundsException
- if the the index is outside the range of existing rows.public void moveRow(int from, int to)
from
- the existing row positionto
- the target position. The "from" item will be moved before that position.public void moveRow2(int from, int to)
moveRow(int, int)
, this
method treats the to-index as the exact row-index where you want to have the
row moved to.
from
- the existing row positionto
- the target position. The "from" item will be moved before that position.public void moveRowLeft(int index)
public void moveRowRight(int index)
public void removeRows()
clear()
public void clear()
public void addRepeaterListener(RepeaterListener listener)
public void removeRepeaterListener(RepeaterListener listener)
public boolean hasRepeaterListeners()
public void broadcastEvent(WidgetEvent event)
AbstractWidget
UnsupportedOperationException
.
Concrete subclass widgets need to override when supporting event broadcasting.
broadcastEvent
in interface Widget
broadcastEvent
in class AbstractWidget
public Widget getWidget(int rowIndex, String id)
rowIndex
- startin from 0id
- a widget id
public void readFromRequest(FormContext formContext)
Widget
readFromRequest
in interface Widget
public boolean validate()
Widget
Widget.generateSaxFragment(ContentHandler, Locale)
method.
validate
in interface Widget
validate
in class AbstractWidget
true
to indicate all validations were ok,
false
otherwiseWidget.validate()
public String getXMLElementName()
AbstractWidget
AbstractWidget.generateSaxFragment(ContentHandler, Locale)
to produce the wrapping element for all the XML-instance-content of this Widget.
getXMLElementName
in class AbstractWidget
public AttributesImpl getXMLElementAttributes()
getXMLElementAttributes
in class AbstractWidget
public void generateDisplayData(ContentHandler contentHandler) throws SAXException
AbstractWidget
AbstractWidget.getDefinition()
of this widget to generate a common
set of 'display' data. (i.e. help, label, hint,...)
Subclasses should override if the getDefinition can return null
to avoid NPE's.
generateDisplayData
in class AbstractWidget
contentHandler
- where to send the SAX events to.
SAXException
WidgetDefinition.generateDisplayData(ContentHandler)
public void generateItemSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException
AbstractWidget
AbstractWidget.generateSaxFragment(ContentHandler, Locale)
The implementation on the AbstractWidget level inserts no additional XML.
Subclasses need to override to insert widget specific content.
generateItemSaxFragment
in class AbstractWidget
contentHandler
- to send the SAX events tolocale
- in which context potential content needs to be put.
SAXException
public void generateWidgetLabel(String widgetId, ContentHandler contentHandler) throws SAXException
SAXException
public void generateSize(ContentHandler contentHandler) throws SAXException
SAXException
public ValidationError getValidationError()
getValidationError
in interface ValidationErrorAware
public void setValidationError(ValidationError error)
setValidationError
in interface ValidationErrorAware
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |