summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java
diff options
context:
space:
mode:
Diffstat (limited to 'projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java')
-rw-r--r--projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java295
1 files changed, 145 insertions, 150 deletions
diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java
index afa118a..53615a4 100644
--- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java
+++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java
@@ -25,155 +25,150 @@ import net.wotonomy.foundation.NSDictionary;
public class WORepetition extends WODynamicElement {
- protected int count;
- protected int index;
- protected Object item;
- protected Collection list;
- protected Iterator iterator;
-
- protected WORepetition() {
- super();
- }
-
- public WORepetition(String aName, NSDictionary aMap, WOElement template) {
- super(aName, aMap, template);
- }
-
- public void setCount(int value) {
- count = value;
- }
-
- public int count() {
- return count;
- }
-
- public void setIndex(int value) {
- index = value;
- }
- public int index() {
- return index;
- }
-
- public void setItem(Object value) {
- item = value;
- }
- public Object item() {
- return item;
- }
-
- public void setList(Collection value) {
- list = value;
- }
- public Collection list() {
- return list;
- }
-
- public void takeValuesFromRequest(WORequest r, WOContext c) {
- c.appendZeroElementIDComponent();
- pullValuesFromParent(c.component());
- index = 0;
- WOAssociation countAsoc = (WOAssociation)associations.objectForKey("count");
- item = getNextItem();
- while (item != null) {
- pushValuesToParent(c.component());
- rootElement.takeValuesFromRequest(r, c);
- index++;
- c.incrementLastElementIDComponent();
- if (countAsoc != null && index >= count())
- item = null;
- else
- item = getNextItem();
- }
- iterator = null;
- c.deleteLastElementIDComponent();
- }
-
- public WOActionResults invokeAction(WORequest r, WOContext c) {
- c.appendZeroElementIDComponent();
- pullValuesFromParent(c.component());
- index = 0;
- WOAssociation countAsoc = (WOAssociation)associations.objectForKey("count");
- item = getNextItem();
- while (item != null) {
- pushValuesToParent(c.component());
- WOActionResults e = rootElement.invokeAction(r, c);
- if (e != null)
- {
- iterator = null;
- return e;
- }
- index++;
- c.incrementLastElementIDComponent();
- if (countAsoc != null && index >= count())
- item = null;
- else
- item = getNextItem();
- }
- iterator = null;
- c.deleteLastElementIDComponent();
- return null;
- }
-
- public void appendToResponse(WOResponse r, WOContext c) {
- c.appendZeroElementIDComponent();
- pullValuesFromParent(c.component());
- index = 0;
- WOAssociation countAsoc = (WOAssociation)associations.objectForKey("count");
- item = getNextItem();
- while (item != null) {
- pushValuesToParent(c.component());
- rootElement.appendToResponse(r, c);
- index++;
- c.incrementLastElementIDComponent();
- if (countAsoc != null || index < count())
- item = null;
- else
- item = getNextItem();
- }
- iterator = null;
- c.deleteLastElementIDComponent();
- }
-
- protected Object getNextItem() {
- if ( iterator == null )
- {
- if ( list == null ) return null;
- iterator = list.iterator();
- }
- if ( iterator.hasNext() )
- {
- return iterator.next();
- }
- return null;
- }
-
- protected void pullValuesFromParent(WOComponent c) {
- Object value;
-
- value = valueForProperty("count", c);
- if ( value instanceof Number )
- {
- setCount( ((Number)value).intValue() );
- }
- else
- {
- setCount( -1 );
- }
-
- value = valueForProperty("list", c);
- if ( value instanceof Collection )
- {
- setList( (Collection) value );
- }
- else
- {
- setList( null );
- }
- }
-
- protected void pushValuesToParent(WOComponent c) {
- setValueForProperty("index", new Integer(index), c);
- setValueForProperty("item", item, c);
- }
+ protected int count;
+ protected int index;
+ protected Object item;
+ protected Collection list;
+ protected Iterator iterator;
+
+ protected WORepetition() {
+ super();
+ }
+
+ public WORepetition(String aName, NSDictionary aMap, WOElement template) {
+ super(aName, aMap, template);
+ }
+
+ public void setCount(int value) {
+ count = value;
+ }
+
+ public int count() {
+ return count;
+ }
+
+ public void setIndex(int value) {
+ index = value;
+ }
+
+ public int index() {
+ return index;
+ }
+
+ public void setItem(Object value) {
+ item = value;
+ }
+
+ public Object item() {
+ return item;
+ }
+
+ public void setList(Collection value) {
+ list = value;
+ }
+
+ public Collection list() {
+ return list;
+ }
+
+ public void takeValuesFromRequest(WORequest r, WOContext c) {
+ c.appendZeroElementIDComponent();
+ pullValuesFromParent(c.component());
+ index = 0;
+ WOAssociation countAsoc = (WOAssociation) associations.objectForKey("count");
+ item = getNextItem();
+ while (item != null) {
+ pushValuesToParent(c.component());
+ rootElement.takeValuesFromRequest(r, c);
+ index++;
+ c.incrementLastElementIDComponent();
+ if (countAsoc != null && index >= count())
+ item = null;
+ else
+ item = getNextItem();
+ }
+ iterator = null;
+ c.deleteLastElementIDComponent();
+ }
+
+ public WOActionResults invokeAction(WORequest r, WOContext c) {
+ c.appendZeroElementIDComponent();
+ pullValuesFromParent(c.component());
+ index = 0;
+ WOAssociation countAsoc = (WOAssociation) associations.objectForKey("count");
+ item = getNextItem();
+ while (item != null) {
+ pushValuesToParent(c.component());
+ WOActionResults e = rootElement.invokeAction(r, c);
+ if (e != null) {
+ iterator = null;
+ return e;
+ }
+ index++;
+ c.incrementLastElementIDComponent();
+ if (countAsoc != null && index >= count())
+ item = null;
+ else
+ item = getNextItem();
+ }
+ iterator = null;
+ c.deleteLastElementIDComponent();
+ return null;
+ }
+
+ public void appendToResponse(WOResponse r, WOContext c) {
+ c.appendZeroElementIDComponent();
+ pullValuesFromParent(c.component());
+ index = 0;
+ WOAssociation countAsoc = (WOAssociation) associations.objectForKey("count");
+ item = getNextItem();
+ while (item != null) {
+ pushValuesToParent(c.component());
+ rootElement.appendToResponse(r, c);
+ index++;
+ c.incrementLastElementIDComponent();
+ if (countAsoc != null || index < count())
+ item = null;
+ else
+ item = getNextItem();
+ }
+ iterator = null;
+ c.deleteLastElementIDComponent();
+ }
+
+ protected Object getNextItem() {
+ if (iterator == null) {
+ if (list == null)
+ return null;
+ iterator = list.iterator();
+ }
+ if (iterator.hasNext()) {
+ return iterator.next();
+ }
+ return null;
+ }
+
+ protected void pullValuesFromParent(WOComponent c) {
+ Object value;
+
+ value = valueForProperty("count", c);
+ if (value instanceof Number) {
+ setCount(((Number) value).intValue());
+ } else {
+ setCount(-1);
+ }
+
+ value = valueForProperty("list", c);
+ if (value instanceof Collection) {
+ setList((Collection) value);
+ } else {
+ setList(null);
+ }
+ }
+
+ protected void pushValuesToParent(WOComponent c) {
+ setValueForProperty("index", new Integer(index), c);
+ setValueForProperty("item", item, c);
+ }
}