You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by br...@apache.org on 2004/03/25 17:41:48 UTC
cvs commit: cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel AbstractWidget.java Form.java Widget.java
bruno 2004/03/25 08:41:48
Modified: src/blocks/forms/java/org/apache/cocoon/forms/formmodel
AbstractWidget.java Form.java Widget.java
Log:
Moved attributes concept from Form to Widget.
Revision Changes Path
1.3 +21 -5 cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java
Index: AbstractWidget.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractWidget.java 9 Mar 2004 13:08:45 -0000 1.2
+++ AbstractWidget.java 25 Mar 2004 16:41:47 -0000 1.3
@@ -15,10 +15,7 @@
*/
package org.apache.cocoon.forms.formmodel;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
+import java.util.*;
import org.apache.cocoon.forms.Constants;
import org.apache.cocoon.forms.FormContext;
@@ -41,6 +38,7 @@
protected AbstractWidgetDefinition definition;
private List validators;
+ private Map attributes;
/**
* Sets the definition of this widget.
@@ -192,5 +190,23 @@
contentHandler.startElement(Constants.INSTANCE_NS, element, Constants.INSTANCE_PREFIX_COLON + element, attrs);
generateItemSaxFragment(contentHandler, locale);
contentHandler.endElement(Constants.INSTANCE_NS, element, Constants.INSTANCE_PREFIX_COLON + element);
+ }
+
+ public Object getAttribute(String name) {
+ return this.attributes == null ? null : this.attributes.get(name);
+ }
+
+ public void setAttribute(String name, Object value) {
+ if (this.attributes == null) {
+ this.attributes = new HashMap();
+ }
+
+ this.attributes.put(name, value);
+ }
+
+ public void removeAttribute(String name) {
+ if (this.attributes != null) {
+ this.attributes.remove(name);
+ }
}
}
1.5 +1 -22 cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Form.java
Index: Form.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Form.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Form.java 11 Mar 2004 02:56:33 -0000 1.4
+++ Form.java 25 Mar 2004 16:41:48 -0000 1.5
@@ -15,10 +15,8 @@
*/
package org.apache.cocoon.forms.formmodel;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
-import java.util.Map;
import java.util.StringTokenizer;
import org.apache.cocoon.forms.Constants;
@@ -54,7 +52,6 @@
private ProcessingPhase phase = ProcessingPhase.LOAD_MODEL;
private boolean isValid = false;
private ProcessingPhaseListener listener;
- private Map attributes;
public Form(FormDefinition definition) {
super(definition);
@@ -280,24 +277,6 @@
public boolean doValidate(FormContext formContext) {
return super.validate(formContext);
- }
-
- public Object getAttribute(String name) {
- return this.attributes == null ? null : this.attributes.get(name);
- }
-
- public void setAttribute(String name, Object value) {
- if (this.attributes == null) {
- this.attributes = new HashMap();
- }
-
- this.attributes.put(name, value);
- }
-
- public void removeAttribute(String name) {
- if (this.attributes != null) {
- this.attributes.remove(name);
- }
}
private static final String FORM_EL = "form";
1.3 +11 -1 cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Widget.java
Index: Widget.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Widget.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Widget.java 11 Mar 2004 02:56:33 -0000 1.2
+++ Widget.java 25 Mar 2004 16:41:48 -0000 1.3
@@ -155,4 +155,14 @@
* Broadcast an event previously queued by this widget to its event listeners.
*/
public void broadcastEvent(WidgetEvent event);
+
+ public Object getAttribute(String name);
+
+ /**
+ * Sets an attribute on this widget. This can be used to store custom
+ * data with each widget.
+ */
+ public void setAttribute(String name, Object value);
+
+ public void removeAttribute(String name);
}