You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2006/04/13 09:26:10 UTC
svn commit: r393749 - in /cocoon: branches/BRANCH_2_1_X/
trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/
trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/generation/
trunk/bl...
Author: cziegeler
Date: Thu Apr 13 00:26:06 2006
New Revision: 393749
URL: http://svn.apache.org/viewcvs?rev=393749&view=rev
Log:
Add id, state and listening attributes to the transformed form-template element (jx macros
and forms transformer).
Modified:
cocoon/branches/BRANCH_2_1_X/status.xml
cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java
cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java
cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/transformation/EffectWidgetReplacingPipe.java
Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?rev=393749&r1=393748&r2=393749&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Thu Apr 13 00:26:06 2006
@@ -181,7 +181,10 @@
<release version="@version@" date="@date@">
-->
<release version="2.1.10" date="TBD">
- <action dev="NN" type="add">DUMMY</action>
+ <action dev="CZ" type="add" fixes-bug="COCOON-1820">
+ CForms: Add id, state and listening attributes to the transformed form-template element (jx macros
+ and forms transformer).
+ </action>
<action dev="AN" type="add">
XSP block: Use private methods to call start/endElement in xsp.xsl.
That generates smaller bytecode allowing to compiler larger XSPs before hitting the
Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java?rev=393749&r1=393748&r2=393749&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java Thu Apr 13 00:26:06 2006
@@ -423,7 +423,7 @@
*/
protected AttributesImpl getXMLElementAttributes() {
AttributesImpl attrs = new AttributesImpl();
- // top-level widget-containers like forms will have their id set to ""
+ // top-level widget-containers like forms might have their id set to ""
// for those the @id should not be included.
if (getId().length() != 0) {
attrs.addCDATAAttribute("id", getRequestParameterName());
Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java?rev=393749&r1=393748&r2=393749&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java Thu Apr 13 00:26:06 2006
@@ -27,6 +27,7 @@
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.forms.FormsConstants;
import org.apache.cocoon.forms.FormsRuntimeException;
+import org.apache.cocoon.forms.event.ValueChangedListenerEnabled;
import org.apache.cocoon.forms.formmodel.Form;
import org.apache.cocoon.forms.formmodel.Repeater;
import org.apache.cocoon.forms.formmodel.Widget;
@@ -98,10 +99,29 @@
// build attributes
AttributesImpl attrs = new AttributesImpl();
+ // top-level widget-containers like forms might have their id set to ""
+ // for those the @id should not be included.
+ if (form.getId().length() != 0) {
+ attrs.addCDATAAttribute("id", form.getRequestParameterName());
+ }
+
+ // Add the "state" attribute
+ attrs.addCDATAAttribute("state", form.getCombinedState().getName());
+
+ // Add the "listening" attribute is the value has change listeners
+ if (form instanceof ValueChangedListenerEnabled &&
+ ((ValueChangedListenerEnabled)form).hasValueChangedListeners()) {
+ attrs.addCDATAAttribute("listening", "true");
+ }
Iterator iter = attributes.entrySet().iterator();
while(iter.hasNext()) {
Map.Entry entry = (Map.Entry)iter.next();
- attrs.addCDATAAttribute((String)entry.getKey(), (String)entry.getValue());
+ final String attrName = (String)entry.getKey();
+ // check if the attribute has already been defined
+ if ( attrs.getValue(attrName) != null ) {
+ attrs.removeAttribute(attrName);
+ }
+ attrs.addCDATAAttribute(attrName, (String)entry.getValue());
}
this.ajaxTemplate = "true".equals(attributes.get("ajax"));
Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/transformation/EffectWidgetReplacingPipe.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/transformation/EffectWidgetReplacingPipe.java?rev=393749&r1=393748&r2=393749&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/transformation/EffectWidgetReplacingPipe.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/transformation/EffectWidgetReplacingPipe.java Thu Apr 13 00:26:06 2006
@@ -16,6 +16,7 @@
package org.apache.cocoon.forms.transformation;
import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.forms.event.ValueChangedListenerEnabled;
import org.apache.cocoon.forms.formmodel.AggregateField;
import org.apache.cocoon.forms.formmodel.DataWidget;
import org.apache.cocoon.forms.formmodel.Group;
@@ -27,6 +28,7 @@
import org.apache.cocoon.forms.validation.ValidationErrorAware;
import org.apache.cocoon.i18n.I18nUtils;
import org.apache.cocoon.xml.AbstractXMLPipe;
+import org.apache.cocoon.xml.AttributesImpl;
import org.apache.cocoon.xml.SaxBuffer;
import org.apache.cocoon.xml.XMLUtils;
@@ -35,7 +37,6 @@
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.helpers.AttributesImpl;
import java.util.ArrayList;
import java.util.HashMap;
@@ -391,6 +392,25 @@
// ====> Check if form visible (and skip it if it's not)
if (!isVisible(contextWidget)) {
return hNull;
+ }
+
+ // set some general attributes
+ // top-level widget-containers like forms might have their id set to ""
+ // for those the @id should not be included.
+ if (contextWidget.getId().length() != 0 && newAttrs.getValue("id") == null ) {
+ newAttrs.addCDATAAttribute("id", contextWidget.getRequestParameterName());
+ }
+
+ // Add the "state" attribute
+ if ( newAttrs.getValue("state") == null ) {
+ newAttrs.addCDATAAttribute("state", contextWidget.getCombinedState().getName());
+ }
+
+ // Add the "listening" attribute is the value has change listeners
+ if (contextWidget instanceof ValueChangedListenerEnabled &&
+ ((ValueChangedListenerEnabled)contextWidget).hasValueChangedListeners() &&
+ newAttrs.getValue("listening") == null ) {
+ newAttrs.addCDATAAttribute("listening", "true");
}
// ====> Determine the Locale