mpo 2004/04/22 01:05:00
Modified: src/blocks/forms/java/org/apache/cocoon/forms/formmodel
AbstractWidget.java
Log:
Fixing the @id addition for the case of top-level widgets (who's getId() will
be "")
+ More info in javadocs
Revision Changes Path
1.10 +22 -10
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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AbstractWidget.java 21 Apr 2004 21:10:05 -0000 1.9
+++ AbstractWidget.java 22 Apr 2004 08:05:00 -0000 1.10
@@ -276,11 +276,19 @@
* Concrete subclasses should call super.getXMLElementAttributes and
possibly
* add additional attributes.
*
- * @return the attributes for the main element for this widget's
sax-fragment.
+ * Note: the @id is not added for those widgets who's getId() returns
<code>null</code>
+ * (e.g. top-level container widgets like 'form'). The contract of
returning a non-null
+ * [EMAIL PROTECTED] AttributesImpl} is however maintained.
+ *
+ * @return the attributes for the main element for this widget's
sax-fragment.
*/
public AttributesImpl getXMLElementAttributes() {
AttributesImpl attrs = new AttributesImpl();
- attrs.addCDATAAttribute("id", getFullyQualifiedId());
+ // top-level widget-containers like forms will have their id set to
""
+ // for those the @id should not be included.
+ if (getId().length() == 0) {
+ attrs.addCDATAAttribute("id", getFullyQualifiedId());
+ }
return attrs;
}
@@ -306,7 +314,16 @@
* This will generate some standard XML consisting of a simple wrapper
* element (name provided by [EMAIL PROTECTED] #getXMLElementName()})
with attributes
* (provided by [EMAIL PROTECTED] #getXMLElementAttributes()} around
anything injected
- * in by [EMAIL PROTECTED] #generateItemSaxFragment(ContentHandler,
Locale)}.
+ * in by both [EMAIL PROTECTED] #generateDisplayData(ContentHandler)} and
+ * [EMAIL PROTECTED] #generateItemSaxFragment(ContentHandler, Locale)}.
+ *
+ * <pre>
+ * <fi:[EMAIL PROTECTED] #getXMLElementName()} [EMAIL PROTECTED]
#getXMLElementAttributes() >
+ * [EMAIL PROTECTED] #generateDisplayData(ContentHandler)}
+ *
+ * [EMAIL PROTECTED] #generateItemSaxFragment(ContentHandler, Locale)}
+ * </fi:[EMAIL PROTECTED] #getXMLElementName()} >
+ * </pre>
*
* @param contentHandler to send the SAX events to
* @param locale in which context potential content needs to be put.
@@ -314,12 +331,7 @@
*/
public void generateSaxFragment(ContentHandler contentHandler, Locale
locale)
throws SAXException {
- //TODO: check why there is no call to
getDefinition().generateDisplayData(contentHandler);
- // if we can add it, then the subclass AbstractContainerWidget could
be pulled up here
- // and potentially make this even final?
-
- String element = this.getXMLElementName();
-
+ String element = this.getXMLElementName();
AttributesImpl attrs = getXMLElementAttributes();
contentHandler.startElement(Constants.INSTANCE_NS, element,
Constants.INSTANCE_PREFIX_COLON + element, attrs);