|
Web Dynpro API Documentation | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Application Interface implemented by context nodes. While this class is used when programming dynamically, more convenient, typed subinterfaces of this interface are generated for context nodes whose structure is declared within the Web Dynpro Development Workbench.
Each node holds a list of elements. If the list is not empty, one of the
elements is the "current" element, the "lead selection". The lead selection
can be changed by navigation (relative or absolute). Usually this list is
held exclusively by the node and can only be manipulated via the node. You
can share an
with the node by ICMIObservableListbinding such a list to it. See
bind(Collection) for details.
The node can be filled by binding elements to it.
You can add, remove,
move or swap
elements. Its content can be invalidated. Then, if it
has a supply function (either generated or via
IWDNodeCollectionSupplier), it will call this function upon further
access to refill itself.
A node may have different cardinalities. At design time they are 0..1, 1..1, 0..n and 1..n. At run time there are the flags mandatory (minimum cardinality is 1) and multiple (maximum cardinality greater than 1).
If mandatory is false, the node is initially empty. Then all UI
elements bound to this node are empty and read only. If mandatory is true,
the node is guaranteed to be non-empty upon access. This is very convenient
for value nodes, but take care with model nodes. Because model node elements
require a model instance, the framework can not automatically create
an element to achieve this guarantee (without a supply function) and throws
an exception if the node is empty and you try to access an element.
If multiple is false you may only bind
single element collections to the node. (You may find
java.util.Collections.singletonList(Object) convenient in this
case.)
Besides the lead selection, the node also has a (multiple) selection. You can
add or remove elements from this selection via setSelected(int, boolean).
You can query this selection via isMultiSelected(int).
You can dynamically add value attributes to a node by changing its metadata.
You can add unmapped and
mapped attributes.
A node may have child nodes. These child nodes are automatically maintained
by the framework. Nevertheless you can dynamically add nodes by
changing the metadata. See the several addChild methods in IWDNodeInfo.
Access to child nodes is possible through getChildNode(String, int).
For many of these methods, the Web Dynpro generator generates special type safe variants.
| Field Summary | |
static int |
LEAD_SELECTION
Constant value indicating the use of the lead selection in some methods. |
static int |
NO_SELECTION
Constant value indicating that no element is selected. |
| Method Summary | |
void |
addElement(int index,
IWDNodeElement element)
Adds an element to the node collection at the given index. |
void |
addElement(IWDNodeElement element)
Adds an element to the node collection. |
void |
bind(java.util.Collection items)
With this method you can bind a new Collection to the Node. |
void |
clearSelection()
Clears the Node's multiple selection; does not change the lead selection. |
IWDNodeElement |
createElement()
Creates a new node element of the type used for this value node. |
IWDNodeElement |
createElement(java.lang.Object reference)
Creates a new node element of the type used for this model node. |
IWDNode |
getChildNode(java.lang.String name,
int index)
Returns the child Node with the given name at the given index. |
IWDContext |
getContext()
Returns the context, this node belongs to. |
IWDNodeElement |
getCurrentElement()
Returns the current element (at the lead selection) or null
if no element is selected. |
IWDNodeElement |
getElementAt(int index)
Returns the element at the given index. |
int |
getLeadSelection()
Returns the index of the lead selection or NO_SELECTION if the element list is empty. |
IWDNodeInfo |
getNodeInfo()
Returns the meta data for this node. |
IWDNodeElement |
getParentElement()
Returns the parent element. |
void |
invalidate()
With this method the node will be invalidated. |
boolean |
isEmpty()
Returns whether the element list is empty. |
boolean |
isMultiSelected(int index)
Returns whether the element at the given index is selected. |
boolean |
isSelected(int index)
Deprecated. This method always returns true if the lead
selection is positioned at index. As a consequence it is
not possible to determine if the element at the lead selection also is
selected via multiple selection. Instead, compare index with
getLeadSelection() or use isMultiSelected(int) depending
on your needs. This method may be withdrawn with the first new NetWeaver
release in 2006. |
void |
moveElement(int from,
int to)
Moves an element to another position within the node collection. |
void |
moveFirst()
Moves the lead selection to the first element in the node collection, if the list is not empty. |
void |
moveLast()
Moves the lead selection to the last element in the node collection, if the list is not empty. |
IWDNodeElement |
moveNext()
Moves the lead selection to the next element in the node collection, if such an element exists. |
IWDNodeElement |
movePrevious()
Moves the lead selection to the previous element in the node collection, if such an element exists. |
void |
moveTo(int index)
Moves the lead selection to the element with the given index. |
void |
notifyAllMappedNodes(java.lang.Object payload)
Notifies all (directly and indirectly) mapped Nodes. |
boolean |
removeElement(IWDNodeElement element)
Removes an element from the node collection. |
void |
setLeadSelection(int index)
Sets the lead selection to the given index. |
void |
setSelected(int index,
boolean selected)
Selects or unselects the element at the given index. |
void |
setTreeSelection(IWDNodeElement element)
Sets the lead selections of the whole node's subtree such that the path to the given element is selected and all other nodes are unselected. |
int |
size()
Returns the size of the element list. |
void |
sortElements(java.util.Comparator comparator)
Sorts the elements according to the Comparator. |
void |
swapElements(int index1,
int index2)
Swaps two elements within the node collection. |
boolean |
validate()
With this method the node will be validated. |
| Field Detail |
public static final int NO_SELECTION
public static final int LEAD_SELECTION
| Method Detail |
public IWDContext getContext()
public void bind(java.util.Collection items)
null; in that case the node is valid containing an
empty list.
This collection may contain elements for this node, (in case of mapping) elements of any origin node of this or (for a model node) instances of the model class.
The node internally creates a List of NodeElements, either
being the ones supplied or wrappers thereof. The collection itself is
thrown away. The order of the elements in the List is the order of the
Collection's Iterator.
The Collection must obey the cardinalities of the Node. It is not allowed to bind an empty collection to a Node of cardinality 1..1 or 1..n, and it is not allowed to bind more than one item to a Node of cardinality 0..1 or 1..1.
If the Collection is an ICMIObservableList, the Node behaves
differently. In that case, the list is passed to the origin node (in case
of mapped nodes). This node does not copy the elements and throw the list
away, but uses the list itself to store the elements.
An ICMIObservableList is not accessed at all during
bind, if cardinality is 0..n and the selection cardinality is
is 0..1 or 0..n. Otherwise, isEmpty() or even size()
(cardinality 0..1 or 1..1) is called.
Take care: If a node has an ICMIObservableList attached,
modifications to the node (addElement(IWDNodeElement),
removeElement(IWDNodeElement), sortElements(Comparator)...)
change the list and vice versa!
Warning: Never use bind if the node has a supplying
relation role. You effectively get the node and the underlying model out of
sync. It is a bad practice to use bind outside the supply function, if
there is one, too. Future releases will probably throw an exception in such
cases, but old application will still be allowed to for compatibility
reasons.
items - the collection of items, which should be bound to this nodeContextException - if
ICMIObservableListpublic void invalidate()
Warning:This method is not allowed within a supply function.
ContextException - when called from within a supply function.public boolean validate()
true, if the node has been validated, i.e. has been
invalid beforepublic IWDNodeInfo getNodeInfo()
public IWDNodeElement getElementAt(int index)
index - the index of the elementIndexOutOfBoundsException - if the node does not have such an element.public int size()
public boolean isEmpty()
true if the list is empty
false otherwise.public int getLeadSelection()
setLeadSelection(int)public void setLeadSelection(int index)
index - the index of the elementContextException - if caller tries to reset the selection, but selection is mandatoryIndexOutOfBoundsException - if the given index is not within the element listgetLeadSelection()public void clearSelection()
public boolean isSelected(int index)
true if the lead
selection is positioned at index. As a consequence it is
not possible to determine if the element at the lead selection also is
selected via multiple selection. Instead, compare index with
getLeadSelection() or use isMultiSelected(int) depending
on your needs. This method may be withdrawn with the first new NetWeaver
release in 2006.
index - the index of the elementtrue if the element is selected.public boolean isMultiSelected(int index)
index - the index of the element
public void setSelected(int index,
boolean selected)
index - the index of the elementselected - flag, which indicates, whether the element
should be selected or unselectedpublic void setTreeSelection(IWDNodeElement element)
null to unselect the complete subtree.element - The element that is to be selected in the subtreeContextException - if element is not in this node's
subtree.public IWDNodeElement getCurrentElement()
null
if no element is selected.null
if no element is selected.public IWDNodeElement getParentElement()
null, if there is no such
element. The parent element is the one element of the parent node that
this node refers to. In case of the context root node, there is none. In
case of independent nodes, it is the one element of the root node. In case
of singleton nodes, it is the parent's lead selection element. In case of
non-singleton, the node exists once for each element of the parent and this
method returns exactly this element.null if there is nonepublic void addElement(IWDNodeElement element)
element - An element that matches the node.ContextException - if the element does not match the node or if the
node is singleton and the parent node has no valid lead selection element.
public void addElement(int index,
IWDNodeElement element)
element - An element that matches the node.index - the index where the element shall be insertedContextException - if the element does not match the node or if the
node is singleton and the parent node has no valid lead selection element.public boolean removeElement(IWDNodeElement element)
element - The element to be removedtrue if the element was in.
public void moveElement(int from,
int to)
from - the index of the element to be moved.to - the index it shall be moved to.java.lang.IllegalArgumentException - if either from or
to are invalid indexes
public void swapElements(int index1,
int index2)
index1 - the index of the one elementindex2 - the index of the other elementjava.lang.IllegalArgumentException - if either index1 or
index2 are invalid indexespublic void moveFirst()
public void moveLast()
public IWDNodeElement movePrevious()
null
and does not change the lead selection.null if there
is nonepublic IWDNodeElement moveNext()
null
and does not change the lead selection.null if there
is nonepublic void moveTo(int index)
index - the index of the elementIndexOutOfBoundsException - if index is within the range of the node collection
public IWDNode getChildNode(java.lang.String name,
int index)
getLeadSelection() are allowed.
Returns null if no node with that name exist.name - the name of the child nodeindex - the index of the elementjava.lang.IllegalArgumentException - if index is not within the range of the node
collection (all nodes) or if index doesn't represent the lead selection index
(singleton nodes only)public IWDNodeElement createElement()
The element is not yet inserted in the node collection,
its IWDNodeElement.node() method will return null.
public IWDNodeElement createElement(java.lang.Object reference)
The element is not yet inserted in the node collection,
its IWDNodeElement.node() method will return null.
reference - a reference to a model instance holding the data for this
node elementpublic void sortElements(java.util.Comparator comparator)
Collections.sort(List) is
used, this sort is guaranteed to be stable: equal elements will not
be reordered as a result of the sort.
Note that the element list is only sorted once. Further adds will again be at the end of the list rendering it unsorted again.
If an ICMIObservableList is bound to the node, this list is sorted!
comparator - a Comparator for IWDNodeElements of this
node.public void notifyAllMappedNodes(java.lang.Object payload)
Warning: For technical reasons, this notification will only be sent to nodes that have been touched at least once. The reason is that the mapping links are set up upon first access. Before that an origin node does not even know that there is another node mapping to it.
payload - The payload is passed to all nodes with the notification.IWDNodeNotificationListener,
IWDNodeInfo.addNotificationListener(IWDNodeNotificationListener),
validate()
|
Web Dynpro API Documentation | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||