You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by mp...@apache.org on 2004/04/22 16:26:49 UTC
cvs commit: cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel Upload.java Form.java Action.java Messages.java Repeater.java Field.java MultiValueField.java Output.java BooleanField.java AggregateField.java
mpo 2004/04/22 07:26:48
Modified: src/blocks/forms/java/org/apache/cocoon/forms/formmodel
Upload.java Form.java Action.java Messages.java
Repeater.java Field.java MultiValueField.java
Output.java BooleanField.java AggregateField.java
Log:
Making the SAXFragment generation benefit better from the implementation in the base class.
Important: This changes the generation of <fi:form> to group the nested widgets with a <fi:widgets>
(no longer fi:children, this affects only the people that use the forms generator,
e.g. most of the binding samples)
Revision Changes Path
1.7 +18 -17 cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Upload.java
Index: Upload.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Upload.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Upload.java 20 Apr 2004 22:19:27 -0000 1.6
+++ Upload.java 22 Apr 2004 14:26:48 -0000 1.7
@@ -145,17 +145,26 @@
public String getXMLElementName() {
return UPLOAD_EL;
}
+
+
- //TODO: reuse available implementation on superclass
- public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
- AttributesImpl fieldAttrs = new AttributesImpl();
- fieldAttrs.addCDATAAttribute("id", getFullyQualifiedId());
- fieldAttrs.addCDATAAttribute("required", String.valueOf(uploadDefinition.isRequired()));
+ /**
+ * Adds attributes @required, @mime-types
+ */
+ public AttributesImpl getXMLElementAttributes() {
+ // TODO Auto-generated method stub
+ System.out.println("getXMLElementAttributes");
+
+ AttributesImpl attrs = super.getXMLElementAttributes();
+ attrs.addCDATAAttribute("id", getFullyQualifiedId());
+ attrs.addCDATAAttribute("required", String.valueOf(uploadDefinition.isRequired()));
if (uploadDefinition.getMimeTypes() != null) {
- fieldAttrs.addCDATAAttribute("mime-types", uploadDefinition.getMimeTypes());
+ attrs.addCDATAAttribute("mime-types", uploadDefinition.getMimeTypes());
}
- contentHandler.startElement(Constants.INSTANCE_NS, UPLOAD_EL, Constants.INSTANCE_PREFIX_COLON + UPLOAD_EL, fieldAttrs);
-
+ return attrs;
+ }
+
+ public void generateItemSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
if (this.part != null) {
String name = (String)this.part.getHeaders().get("filename");
contentHandler.startElement(Constants.INSTANCE_NS, VALUE_EL, Constants.INSTANCE_PREFIX_COLON + VALUE_EL, XMLUtils.EMPTY_ATTRIBUTES);
@@ -169,14 +178,6 @@
validationError.generateSaxFragment(contentHandler);
contentHandler.endElement(Constants.INSTANCE_NS, VALIDATION_MSG_EL, Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL);
}
-
- // the display data
- this.uploadDefinition.generateDisplayData(contentHandler);
-
- contentHandler.endElement(Constants.INSTANCE_NS, UPLOAD_EL, Constants.INSTANCE_PREFIX_COLON + UPLOAD_EL);
}
- public void generateLabel(ContentHandler contentHandler) throws SAXException {
- this.uploadDefinition.generateLabel(contentHandler);
- }
}
1.9 +1 -28 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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Form.java 20 Apr 2004 22:19:27 -0000 1.8
+++ Form.java 22 Apr 2004 14:26:48 -0000 1.9
@@ -15,11 +15,9 @@
*/
package org.apache.cocoon.forms.formmodel;
-import java.util.Iterator;
import java.util.Locale;
import java.util.StringTokenizer;
-import org.apache.cocoon.forms.Constants;
import org.apache.cocoon.forms.FormContext;
import org.apache.cocoon.forms.event.FormHandler;
import org.apache.cocoon.forms.event.ProcessingPhase;
@@ -27,11 +25,7 @@
import org.apache.cocoon.forms.event.ProcessingPhaseListener;
import org.apache.cocoon.forms.event.WidgetEvent;
import org.apache.cocoon.forms.event.WidgetEventMulticaster;
-import org.apache.cocoon.xml.AttributesImpl;
-import org.apache.cocoon.xml.XMLUtils;
import org.apache.commons.collections.list.CursorableLinkedList;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
/**
* A widget that serves as a container for other widgets, the top-level widget in
@@ -314,25 +308,4 @@
return FORM_EL;
}
- //TODO: reuse available implementation on superclass
- public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
- AttributesImpl formAttrs = new AttributesImpl();
- formAttrs.addCDATAAttribute("id", definition.getId());
- contentHandler.startElement(Constants.INSTANCE_NS, FORM_EL, Constants.INSTANCE_PREFIX_COLON + FORM_EL, XMLUtils.EMPTY_ATTRIBUTES);
- definition.generateLabel(contentHandler);
-
- contentHandler.startElement(Constants.INSTANCE_NS, CHILDREN_EL, Constants.INSTANCE_PREFIX_COLON + CHILDREN_EL, XMLUtils.EMPTY_ATTRIBUTES);
- Iterator widgetIt = widgets.iterator();
- while (widgetIt.hasNext()) {
- Widget widget = (Widget)widgetIt.next();
- widget.generateSaxFragment(contentHandler, locale);
- }
- contentHandler.endElement(Constants.INSTANCE_NS, CHILDREN_EL, Constants.INSTANCE_PREFIX_COLON + CHILDREN_EL);
-
- contentHandler.endElement(Constants.INSTANCE_NS, FORM_EL, Constants.INSTANCE_PREFIX_COLON + FORM_EL);
- }
-
- public void generateLabel(ContentHandler contentHandler) throws SAXException {
- definition.generateLabel(contentHandler);
- }
}
1.6 +1 -21 cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Action.java
Index: Action.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Action.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Action.java 20 Apr 2004 22:19:27 -0000 1.5
+++ Action.java 22 Apr 2004 14:26:48 -0000 1.6
@@ -16,15 +16,9 @@
package org.apache.cocoon.forms.formmodel;
import org.apache.cocoon.environment.Request;
-import org.apache.cocoon.forms.Constants;
import org.apache.cocoon.forms.FormContext;
import org.apache.cocoon.forms.event.ActionEvent;
import org.apache.cocoon.forms.event.WidgetEvent;
-import org.apache.cocoon.xml.AttributesImpl;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-import java.util.Locale;
/**
* An Action widget. An Action widget can cause an {@link ActionEvent} to be triggered
@@ -105,20 +99,6 @@
public String getXMLElementName() {
return ACTION_EL;
}
-
- //TODO: reuse available implementation on superclass
- public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
- AttributesImpl buttonAttrs = new AttributesImpl();
- buttonAttrs.addCDATAAttribute("id", getFullyQualifiedId());
- contentHandler.startElement(Constants.INSTANCE_NS, ACTION_EL, Constants.INSTANCE_PREFIX_COLON + ACTION_EL, buttonAttrs);
- // generate label, help, hint, etc.
- definition.generateDisplayData(contentHandler);
- contentHandler.endElement(Constants.INSTANCE_NS, ACTION_EL, Constants.INSTANCE_PREFIX_COLON + ACTION_EL);
- }
-
- public void generateLabel(ContentHandler contentHandler) throws SAXException {
- definition.generateLabel(contentHandler);
- }
public void broadcastEvent(WidgetEvent event) {
this.definition.fireActionEvent((ActionEvent)event);
1.7 +2 -12 cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Messages.java
Index: Messages.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Messages.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Messages.java 20 Apr 2004 22:19:27 -0000 1.6
+++ Messages.java 22 Apr 2004 14:26:48 -0000 1.7
@@ -84,12 +84,7 @@
return MESSAGES_EL;
}
- //TODO: reuse available implementation on superclass
- public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
- contentHandler.startElement(Constants.INSTANCE_NS, MESSAGES_EL, Constants.INSTANCE_PREFIX_COLON + MESSAGES_EL, XMLUtils.EMPTY_ATTRIBUTES);
-
- definition.generateDisplayData(contentHandler);
-
+ public void generateItemSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
Iterator messagesIt = messages.iterator();
while (messagesIt.hasNext()) {
XMLizable message = (XMLizable)messagesIt.next();
@@ -97,11 +92,6 @@
message.toSAX(contentHandler);
contentHandler.endElement(Constants.INSTANCE_NS, MESSAGE_EL, Constants.INSTANCE_PREFIX_COLON + MESSAGE_EL);
}
-
- contentHandler.endElement(Constants.INSTANCE_NS, MESSAGES_EL, Constants.INSTANCE_PREFIX_COLON + MESSAGES_EL);
}
- public void generateLabel(ContentHandler contentHandler) throws SAXException {
- definition.generateLabel(contentHandler);
- }
}
1.9 +42 -45 cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Repeater.java
Index: Repeater.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Repeater.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Repeater.java 21 Apr 2004 13:33:37 -0000 1.8
+++ Repeater.java 22 Apr 2004 14:26:48 -0000 1.9
@@ -249,16 +249,23 @@
return REPEATER_EL;
}
- //TODO: reuse available implementation on superclass
- public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
- AttributesImpl repeaterAttrs = new AttributesImpl();
- repeaterAttrs.addCDATAAttribute("id", getFullyQualifiedId());
- repeaterAttrs.addCDATAAttribute("size", String.valueOf(getSize()));
- contentHandler.startElement(Constants.INSTANCE_NS, REPEATER_EL, Constants.INSTANCE_PREFIX_COLON + REPEATER_EL, repeaterAttrs);
-
+
+
+ /**
+ * Adds @size attribute
+ */
+ public AttributesImpl getXMLElementAttributes() {
+ AttributesImpl attrs = super.getXMLElementAttributes();
+ attrs.addCDATAAttribute("size", String.valueOf(getSize()));
+ return attrs;
+ }
+
+
+ public void generateDisplayData(ContentHandler contentHandler)
+ throws SAXException {
// the repeater's label
contentHandler.startElement(Constants.INSTANCE_NS, LABEL_EL, Constants.INSTANCE_PREFIX_COLON + LABEL_EL, XMLUtils.EMPTY_ATTRIBUTES);
- definition.generateLabel(contentHandler);
+ generateLabel(contentHandler);
contentHandler.endElement(Constants.INSTANCE_NS, LABEL_EL, Constants.INSTANCE_PREFIX_COLON + LABEL_EL);
// heading element -- currently contains the labels of each widget in the repeater
@@ -271,18 +278,16 @@
contentHandler.endElement(Constants.INSTANCE_NS, HEADING_EL, Constants.INSTANCE_PREFIX_COLON + HEADING_EL);
}
contentHandler.endElement(Constants.INSTANCE_NS, HEADINGS_EL, Constants.INSTANCE_PREFIX_COLON + HEADINGS_EL);
-
+ }
+
+
+ public void generateItemSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
// the actual rows in the repeater
Iterator rowIt = rows.iterator();
while (rowIt.hasNext()) {
RepeaterRow row = (RepeaterRow)rowIt.next();
row.generateSaxFragment(contentHandler, locale);
}
- contentHandler.endElement(Constants.INSTANCE_NS, REPEATER_EL, Constants.INSTANCE_PREFIX_COLON + REPEATER_EL);
- }
-
- public void generateLabel(ContentHandler contentHandler) throws SAXException {
- definition.generateLabel(contentHandler);
}
/**
@@ -300,9 +305,7 @@
* Generates a repeater-size element with a size attribute indicating the size of this repeater.
*/
public void generateSize(ContentHandler contentHandler) throws SAXException {
- AttributesImpl attrs = new AttributesImpl();
- attrs.addCDATAAttribute("id", getFullyQualifiedId());
- attrs.addCDATAAttribute("size", String.valueOf(getSize()));
+ AttributesImpl attrs = getXMLElementAttributes();
contentHandler.startElement(Constants.INSTANCE_NS, REPEATER_SIZE_EL, Constants.INSTANCE_PREFIX_COLON + REPEATER_SIZE_EL, attrs);
contentHandler.endElement(Constants.INSTANCE_NS, REPEATER_SIZE_EL, Constants.INSTANCE_PREFIX_COLON + REPEATER_SIZE_EL);
}
@@ -353,12 +356,7 @@
private static final String ROW_EL = "repeater-row";
- public void generateLabel(ContentHandler contentHandler) throws SAXException {
- // this widget has no label
- }
-
-
/**
* @return "repeater-row"
*/
@@ -366,31 +364,30 @@
return ROW_EL;
}
- //TODO: reuse available implementation on superclass
- public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
- AttributesImpl rowAttrs = new AttributesImpl();
- rowAttrs.addCDATAAttribute("id", getFullyQualifiedId());
- contentHandler.startElement(Constants.INSTANCE_NS, ROW_EL, Constants.INSTANCE_PREFIX_COLON + ROW_EL, rowAttrs);
- Iterator widgetIt = widgets.iterator();
- while (widgetIt.hasNext()) {
- Widget widget = (Widget)widgetIt.next();
- widget.generateSaxFragment(contentHandler, locale);
- }
- contentHandler.endElement(Constants.INSTANCE_NS, ROW_EL, Constants.INSTANCE_PREFIX_COLON + ROW_EL);
- }
+ public void generateLabel(ContentHandler contentHandler) throws SAXException {
+ // this widget has its label generated in the context of the repeater
+ }
+
+ public void generateDisplayData(ContentHandler contentHandler)
+ throws SAXException {
+ // this widget has its display-data generated in the context of the repeater
+ }
+
+// //TODO: reuse available implementation on superclass
+// public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
+// AttributesImpl rowAttrs = new AttributesImpl();
+// rowAttrs.addCDATAAttribute("id", getFullyQualifiedId());
+// contentHandler.startElement(Constants.INSTANCE_NS, ROW_EL, Constants.INSTANCE_PREFIX_COLON + ROW_EL, rowAttrs);
+// Iterator widgetIt = widgets.iterator();
+// while (widgetIt.hasNext()) {
+// Widget widget = (Widget)widgetIt.next();
+// widget.generateSaxFragment(contentHandler, locale);
+// }
+// contentHandler.endElement(Constants.INSTANCE_NS, ROW_EL, Constants.INSTANCE_PREFIX_COLON + ROW_EL);
+// }
public void broadcastEvent(WidgetEvent event) {
throw new UnsupportedOperationException("Widget " + this.getFullyQualifiedId() + " doesn't handle events.");
}
}
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.forms.formmodel.ContainerWidget#getChildren()
- */
-// public Iterator getChildren() {
-// // TODO Auto-generated method stub to make this compile again
-// return null;
-// }
-
-
}
1.9 +12 -17 cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java
Index: Field.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Field.java 20 Apr 2004 22:19:27 -0000 1.8
+++ Field.java 22 Apr 2004 14:26:48 -0000 1.9
@@ -225,14 +225,17 @@
public String getXMLElementName() {
return FIELD_EL;
}
-
- //TODO: reuse available implementation on superclass
- public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
- AttributesImpl fieldAttrs = new AttributesImpl();
- fieldAttrs.addCDATAAttribute("id", getFullyQualifiedId());
- fieldAttrs.addCDATAAttribute("required", String.valueOf(isRequired()));
- contentHandler.startElement(Constants.INSTANCE_NS, FIELD_EL, Constants.INSTANCE_PREFIX_COLON + FIELD_EL, fieldAttrs);
-
+
+ /**
+ * Adds the @required attribute
+ */
+ public AttributesImpl getXMLElementAttributes() {
+ AttributesImpl attrs = super.getXMLElementAttributes();
+ attrs.addCDATAAttribute("required", String.valueOf(isRequired()));
+ return attrs;
+ }
+
+ public void generateItemSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
if (enteredValue != null || value != null) {
contentHandler.startElement(Constants.INSTANCE_NS, VALUE_EL, Constants.INSTANCE_PREFIX_COLON + VALUE_EL, XMLUtils.EMPTY_ATTRIBUTES);
String stringValue;
@@ -252,9 +255,6 @@
contentHandler.endElement(Constants.INSTANCE_NS, VALIDATION_MSG_EL, Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL);
}
- // generate label, help, hint, etc.
- fieldDefinition.generateDisplayData(contentHandler);
-
// generate selection list, if any
if (selectionList != null) {
selectionList.generateSaxFragment(contentHandler, locale);
@@ -264,13 +264,8 @@
// include some info about the datatype
fieldDefinition.getDatatype().generateSaxFragment(contentHandler, locale);
-
- contentHandler.endElement(Constants.INSTANCE_NS, FIELD_EL, Constants.INSTANCE_PREFIX_COLON + FIELD_EL);
}
- public void generateLabel(ContentHandler contentHandler) throws SAXException {
- fieldDefinition.generateLabel(contentHandler);
- }
/**
* Set this field's selection list.
1.7 +5 -19 cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MultiValueField.java
Index: MultiValueField.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MultiValueField.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MultiValueField.java 20 Apr 2004 22:19:27 -0000 1.6
+++ MultiValueField.java 22 Apr 2004 14:26:48 -0000 1.7
@@ -15,6 +15,8 @@
*/
package org.apache.cocoon.forms.formmodel;
+import java.util.Locale;
+
import org.apache.cocoon.forms.Constants;
import org.apache.cocoon.forms.FormContext;
import org.apache.cocoon.forms.datatype.SelectionList;
@@ -23,13 +25,10 @@
import org.apache.cocoon.forms.util.I18nMessage;
import org.apache.cocoon.forms.validation.ValidationError;
import org.apache.cocoon.forms.validation.ValidationErrorAware;
-import org.apache.cocoon.xml.AttributesImpl;
import org.apache.cocoon.xml.XMLUtils;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
-import java.util.Locale;
-
/**
* A MultiValueField is mostly the same as a normal {@link Field}, but can
* hold multiple values. A MultiValueField should have a Datatype which
@@ -117,12 +116,7 @@
return MULTIVALUEFIELD_EL;
}
- //TODO: reuse available implementation on superclass
- public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
- AttributesImpl attrs = new AttributesImpl();
- attrs.addCDATAAttribute("id", getFullyQualifiedId());
- contentHandler.startElement(Constants.INSTANCE_NS, MULTIVALUEFIELD_EL, Constants.INSTANCE_PREFIX_COLON + MULTIVALUEFIELD_EL, attrs);
-
+ public void generateItemSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
contentHandler.startElement(Constants.INSTANCE_NS, VALUES_EL, Constants.INSTANCE_PREFIX_COLON + VALUES_EL, XMLUtils.EMPTY_ATTRIBUTES);
if (values != null) {
for (int i = 0; i < values.length; i++) {
@@ -141,9 +135,6 @@
}
contentHandler.endElement(Constants.INSTANCE_NS, VALUES_EL, Constants.INSTANCE_PREFIX_COLON + VALUES_EL);
- // generate label, help, hint, etc.
- definition.generateDisplayData(contentHandler);
-
// the selection list (a MultiValueField has per definition always a SelectionList)
if (this.selectionList != null) {
this.selectionList.generateSaxFragment(contentHandler, locale);
@@ -157,14 +148,9 @@
validationError.generateSaxFragment(contentHandler);
contentHandler.endElement(Constants.INSTANCE_NS, VALIDATION_MSG_EL, Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL);
}
-
- contentHandler.endElement(Constants.INSTANCE_NS, MULTIVALUEFIELD_EL, Constants.INSTANCE_PREFIX_COLON + MULTIVALUEFIELD_EL);
- }
-
- public void generateLabel(ContentHandler contentHandler) throws SAXException {
- definition.generateLabel(contentHandler);
}
+
public Object getValue() {
return values;
}
1.7 +4 -19 cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Output.java
Index: Output.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Output.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Output.java 20 Apr 2004 22:19:27 -0000 1.6
+++ Output.java 22 Apr 2004 14:26:48 -0000 1.7
@@ -15,16 +15,15 @@
*/
package org.apache.cocoon.forms.formmodel;
+import java.util.Locale;
+
import org.apache.cocoon.forms.Constants;
import org.apache.cocoon.forms.FormContext;
import org.apache.cocoon.forms.datatype.Datatype;
-import org.apache.cocoon.xml.AttributesImpl;
import org.apache.cocoon.xml.XMLUtils;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
-import java.util.Locale;
-
/**
* An Output widget can be used to show a non-editable value to the user.
* An Output widget is associated with a certain
@@ -74,12 +73,7 @@
return OUTPUT_EL;
}
- //TODO: reuse available implementation on superclass
- public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
- AttributesImpl outputAttrs = new AttributesImpl();
- outputAttrs.addCDATAAttribute("id", getFullyQualifiedId());
- contentHandler.startElement(Constants.INSTANCE_NS, OUTPUT_EL, Constants.INSTANCE_PREFIX_COLON + OUTPUT_EL, outputAttrs);
-
+ public void generateItemSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
// the value
if (value != null) {
contentHandler.startElement(Constants.INSTANCE_NS, VALUE_EL, Constants.INSTANCE_PREFIX_COLON + VALUE_EL, XMLUtils.EMPTY_ATTRIBUTES);
@@ -88,15 +82,6 @@
contentHandler.characters(stringValue.toCharArray(), 0, stringValue.length());
contentHandler.endElement(Constants.INSTANCE_NS, VALUE_EL, Constants.INSTANCE_PREFIX_COLON + VALUE_EL);
}
-
- // generate label, help, hint, etc.
- definition.generateDisplayData(contentHandler);
-
- contentHandler.endElement(Constants.INSTANCE_NS, OUTPUT_EL, Constants.INSTANCE_PREFIX_COLON + OUTPUT_EL);
- }
-
- public void generateLabel(ContentHandler contentHandler) throws SAXException {
- definition.generateLabel(contentHandler);
}
public Object getValue() {
1.6 +4 -19 cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java
Index: BooleanField.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- BooleanField.java 20 Apr 2004 22:19:27 -0000 1.5
+++ BooleanField.java 22 Apr 2004 14:26:48 -0000 1.6
@@ -15,17 +15,16 @@
*/
package org.apache.cocoon.forms.formmodel;
+import java.util.Locale;
+
import org.apache.cocoon.forms.Constants;
import org.apache.cocoon.forms.FormContext;
import org.apache.cocoon.forms.event.ValueChangedEvent;
import org.apache.cocoon.forms.event.WidgetEvent;
-import org.apache.cocoon.xml.AttributesImpl;
import org.apache.cocoon.xml.XMLUtils;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
-import java.util.Locale;
-
/**
* A widget to select a boolean value. Usually rendered as a checkbox.
*
@@ -87,26 +86,12 @@
return BOOLEAN_FIELD_EL;
}
- //TODO: reuse available implementation on superclass
- public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
- AttributesImpl fieldAttrs = new AttributesImpl();
- fieldAttrs.addCDATAAttribute("id", getFullyQualifiedId());
- contentHandler.startElement(Constants.INSTANCE_NS, BOOLEAN_FIELD_EL, Constants.INSTANCE_PREFIX_COLON + BOOLEAN_FIELD_EL, fieldAttrs);
-
+ public void generateItemSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
// value element
contentHandler.startElement(Constants.INSTANCE_NS, VALUE_EL, Constants.INSTANCE_PREFIX_COLON + VALUE_EL, XMLUtils.EMPTY_ATTRIBUTES);
String stringValue = String.valueOf(value != null && value.booleanValue() == true? "true": "false");
contentHandler.characters(stringValue.toCharArray(), 0, stringValue.length());
contentHandler.endElement(Constants.INSTANCE_NS, VALUE_EL, Constants.INSTANCE_PREFIX_COLON + VALUE_EL);
-
- // generate label, help, hint, etc.
- definition.generateDisplayData(contentHandler);
-
- contentHandler.endElement(Constants.INSTANCE_NS, BOOLEAN_FIELD_EL, Constants.INSTANCE_PREFIX_COLON + BOOLEAN_FIELD_EL);
- }
-
- public void generateLabel(ContentHandler contentHandler) throws SAXException {
- definition.generateLabel(contentHandler);
}
public Object getValue() {
1.5 +13 -54 cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateField.java
Index: AggregateField.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateField.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AggregateField.java 9 Apr 2004 16:43:21 -0000 1.4
+++ AggregateField.java 22 Apr 2004 14:26:48 -0000 1.5
@@ -15,28 +15,22 @@
*/
package org.apache.cocoon.forms.formmodel;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
import org.apache.cocoon.forms.Constants;
import org.apache.cocoon.forms.FormContext;
import org.apache.cocoon.forms.formmodel.AggregateFieldDefinition.SplitMapping;
import org.apache.cocoon.forms.util.I18nMessage;
import org.apache.cocoon.forms.validation.ValidationError;
-import org.apache.cocoon.xml.AttributesImpl;
-import org.apache.cocoon.xml.XMLUtils;
import org.apache.excalibur.xml.sax.XMLizable;
import org.apache.oro.text.regex.MatchResult;
import org.apache.oro.text.regex.PatternMatcher;
import org.apache.oro.text.regex.Perl5Matcher;
-
import org.outerj.expression.ExpressionException;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
/**
* An aggregated field allows to represent one value as multiple input fields, or several values
@@ -204,52 +198,17 @@
return super.validate(formContext);
}
-
private static final String AGGREGATEFIELD_EL = "aggregatefield";
private static final String VALUE_EL = "value";
private static final String VALIDATION_MSG_EL = "validation-message";
- public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
- AttributesImpl aggregatedFieldAttrs = new AttributesImpl();
- aggregatedFieldAttrs.addCDATAAttribute("id", getFullyQualifiedId());
- aggregatedFieldAttrs.addCDATAAttribute("required", String.valueOf(getAggregateFieldDefinition().isRequired()));
- contentHandler.startElement(Constants.INSTANCE_NS, AGGREGATEFIELD_EL, Constants.INSTANCE_PREFIX_COLON + AGGREGATEFIELD_EL, aggregatedFieldAttrs);
-
- if (enteredValue != null || value != null) {
- contentHandler.startElement(Constants.INSTANCE_NS, VALUE_EL, Constants.INSTANCE_PREFIX_COLON + VALUE_EL, XMLUtils.EMPTY_ATTRIBUTES);
- String stringValue;
- if (value != null) {
- stringValue = getDatatype().convertToString(value, locale);
- } else {
- stringValue = enteredValue;
- }
- contentHandler.characters(stringValue.toCharArray(), 0, stringValue.length());
- contentHandler.endElement(Constants.INSTANCE_NS, VALUE_EL, Constants.INSTANCE_PREFIX_COLON + VALUE_EL);
- }
-
- // validation message element: only present if the value is not valid
- if (validationError != null) {
- contentHandler.startElement(Constants.INSTANCE_NS, VALIDATION_MSG_EL, Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL, XMLUtils.EMPTY_ATTRIBUTES);
- validationError.generateSaxFragment(contentHandler);
- contentHandler.endElement(Constants.INSTANCE_NS, VALIDATION_MSG_EL, Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL);
- }
-
- // generate label, help, hint, etc.
- getDefinition().generateDisplayData(contentHandler);
-
- // generate selection list, if any
- if (selectionList != null) {
- selectionList.generateSaxFragment(contentHandler, locale);
- } else if (getFieldDefinition().getSelectionList() != null) {
- getFieldDefinition().getSelectionList().generateSaxFragment(contentHandler, locale);
- }
- contentHandler.endElement(Constants.INSTANCE_NS, AGGREGATEFIELD_EL, Constants.INSTANCE_PREFIX_COLON + AGGREGATEFIELD_EL);
- }
-
- public void generateLabel(ContentHandler contentHandler) throws SAXException {
- getDefinition().generateLabel(contentHandler);
+ /**
+ * @return "aggregatefield"
+ */
+ public String getXMLElementName() {
+ return AGGREGATEFIELD_EL;
}
-
+
public Widget getWidget(String id) {
return (Widget)fieldsById.get(id);
}