cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r307119 - in /cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms: formmodel/ generation/ resources/ transformation/
Date Fri, 07 Oct 2005 13:29:01 GMT
Author: sylvain
Date: Fri Oct  7 06:28:45 2005
New Revision: 307119

URL: http://svn.apache.org/viewcvs?rev=307119&view=rev
Log:
Remove the redundant ft:repeater-error-message instruction, shorten min and max size attributes
names

Modified:
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Repeater.java
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UnionDefinitionBuilder.java
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/jx-macros.xml
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-calendar-styling.xsl
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-field-styling.xsl
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/transformation/EffectWidgetReplacingPipe.java

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Repeater.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Repeater.java?rev=307119&r1=307118&r2=307119&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Repeater.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Repeater.java Fri Oct
 7 06:28:45 2005
@@ -52,7 +52,6 @@
     private static final String HEADING_EL = "heading";
     private static final String LABEL_EL = "label";
     private static final String REPEATER_SIZE_EL = "repeater-size";
-    private static final String REPEATER_VALIDATION_MESSAGE_EL = "repeater-validation-message";
 
     private final RepeaterDefinition definition;
     private final List rows = new ArrayList();
@@ -84,12 +83,12 @@
         return rows.size();
     }
 
-    public int getMinimumSize() {
-        return this.definition.getMinimumSize();
+    public int getMinSize() {
+        return this.definition.getMinSize();
     }
 
-    public int getMaximumSize() {
-        return this.definition.getMaximumSize();
+    public int getMaxSize() {
+        return this.definition.getMaxSize();
     }
 
     public RepeaterRow addRow() {
@@ -285,10 +284,10 @@
             valid = valid & row.validate();
         }
 
-        if (rows.size() > getMaximumSize() || rows.size() < getMinimumSize()) {
+        if (rows.size() > getMaxSize() || rows.size() < getMinSize()) {
             String [] boundaries = new String[2];
-            boundaries[0] = String.valueOf(getMinimumSize());
-            boundaries[1] = String.valueOf(getMaximumSize());
+            boundaries[0] = String.valueOf(getMinSize());
+            boundaries[1] = String.valueOf(getMaxSize());
             this.validationError = new ValidationError(new I18nMessage("repeater.cardinality",
boundaries, Constants.I18N_CATALOGUE));
             valid=false;
         }
@@ -319,8 +318,15 @@
 	public AttributesImpl getXMLElementAttributes() {
         AttributesImpl attrs = super.getXMLElementAttributes();
         attrs.addCDATAAttribute("size", String.valueOf(getSize()));
-        attrs.addCDATAAttribute("minimum-size", String.valueOf(getMinimumSize()));
-        attrs.addCDATAAttribute("maximum-size", String.valueOf(getMaximumSize()));
+        // Generate the min and max sizes if they don't have the default value
+        int size = getMinSize();
+        if (size > 0) {
+            attrs.addCDATAAttribute("min-size", String.valueOf(size));
+        }
+        size = getMaxSize();
+        if (size != Integer.MAX_VALUE) {
+            attrs.addCDATAAttribute("max-size", String.valueOf(size));
+        }
 		return attrs;
 	}
 
@@ -372,14 +378,6 @@
         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);
-    }
-
-    public void generateValidationMessage(ContentHandler contentHandler) throws SAXException
{
-        if (validationError != null ) {
-            contentHandler.startElement(Constants.INSTANCE_NS, REPEATER_VALIDATION_MESSAGE_EL,
Constants.INSTANCE_PREFIX_COLON + REPEATER_VALIDATION_MESSAGE_EL, XMLUtils.EMPTY_ATTRIBUTES);
-            this.validationError.generateSaxFragment(contentHandler);
-            contentHandler.endElement(Constants.INSTANCE_NS, REPEATER_VALIDATION_MESSAGE_EL,
Constants.INSTANCE_PREFIX_COLON + REPEATER_VALIDATION_MESSAGE_EL);
-        }
     }
 
     /**

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java?rev=307119&r1=307118&r2=307119&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java
(original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java
Fri Oct  7 06:28:45 2005
@@ -22,14 +22,14 @@
  */
 public class RepeaterDefinition extends AbstractContainerDefinition {
     private int initialSize = 0;
-    private int minimumSize;
-    private int maximumSize;
+    private int minSize;
+    private int maxSize;
 
     public RepeaterDefinition(int initialSize, int minSize, int maxSize) {
         super();
         this.initialSize = initialSize;
-        this.minimumSize = minSize;
-        this.maximumSize = maxSize;
+        this.minSize = minSize;
+        this.maxSize = maxSize;
     }
     
     /**
@@ -41,8 +41,8 @@
         if(definition instanceof RepeaterDefinition) {
             RepeaterDefinition other = (RepeaterDefinition)definition;
             this.initialSize = other.initialSize;
-            this.maximumSize = other.maximumSize;
-            this.minimumSize = other.minimumSize;
+            this.maxSize = other.maxSize;
+            this.minSize = other.minSize;
         } else {
             throw new Exception("Definition to inherit from is not of the right type! (at
"+getLocation()+")");
         }
@@ -56,11 +56,11 @@
         return this.initialSize;
     }
 
-    public int getMaximumSize() {
-        return this.maximumSize;
+    public int getMaxSize() {
+        return this.maxSize;
     }
 
-    public int getMinimumSize() {
-        return this.minimumSize;
+    public int getMinSize() {
+        return this.minSize;
     }
 }

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java?rev=307119&r1=307118&r2=307119&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java
(original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java
Fri Oct  7 06:28:45 2005
@@ -15,6 +15,7 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
+import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.cocoon.forms.util.DomHelper;
 import org.w3c.dom.Element;
 
@@ -28,20 +29,26 @@
     public WidgetDefinition buildWidgetDefinition(Element repeaterElement) throws Exception
{
         
         int initialSize = DomHelper.getAttributeAsInteger(repeaterElement, "initial-size",
0);
-        int minimumSize = DomHelper.getAttributeAsInteger(repeaterElement, "minimum-size",
0);
-        int maximumSize = DomHelper.getAttributeAsInteger(repeaterElement, "maximum-size",
Integer.MAX_VALUE);
+        int minSize = DomHelper.getAttributeAsInteger(repeaterElement, "min-size", 0);
+        int maxSize = DomHelper.getAttributeAsInteger(repeaterElement, "max-size", Integer.MAX_VALUE);
 
         // should throw error on negative values ? Just correct them for now. 
-        if (minimumSize < 0)
-            minimumSize = 0;
-
-        if (maximumSize < 0)
-            maximumSize = Integer.MAX_VALUE;
+        if (minSize < 0) {
+            throw new ConfigurationException("min-size should be positive, at " + DomHelper.getLocationObject(repeaterElement));
+        }
+        
+        if (maxSize < 0) {
+            throw new ConfigurationException("max-size should be positive, at " + DomHelper.getLocationObject(repeaterElement));
+        }
+        
+        if (maxSize < minSize) {
+            throw new ConfigurationException("max-size should be greater that or equal to
min-size, at " + DomHelper.getLocationObject(repeaterElement));
+        }
 
-        // initialsize is at least the minimumsize
-        initialSize = minimumSize > initialSize ? minimumSize : initialSize;
+        // initial size is at least the min size
+        initialSize = minSize > initialSize ? minSize : initialSize;
                 
-        RepeaterDefinition repeaterDefinition = new RepeaterDefinition(initialSize, minimumSize,
maximumSize);
+        RepeaterDefinition repeaterDefinition = new RepeaterDefinition(initialSize, minSize,
maxSize);
         super.setupDefinition(repeaterElement, repeaterDefinition);
         setDisplayData(repeaterElement, repeaterDefinition);
 

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UnionDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UnionDefinitionBuilder.java?rev=307119&r1=307118&r2=307119&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UnionDefinitionBuilder.java
(original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UnionDefinitionBuilder.java
Fri Oct  7 06:28:45 2005
@@ -28,7 +28,7 @@
     public WidgetDefinition buildWidgetDefinition(Element element) throws Exception {
         UnionDefinition definition = new UnionDefinition();
         super.setupDefinition(element, definition);
-        definition.setCaseWidgetId(DomHelper.getAttribute(element, "case", ""));
+        definition.setCaseWidgetId(DomHelper.getAttribute(element, "case"));
         setDisplayData(element, definition);
 
         setupContainer(element,"widgets",definition);

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java?rev=307119&r1=307118&r2=307119&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java
(original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java
Fri Oct  7 06:28:45 2005
@@ -231,7 +231,18 @@
         return pushWidget(path, true);
     }
 
-    public boolean pushRepeater(String path) throws SAXException {
+    /**
+     * Enter a repeater
+     * 
+     * @param path widget path
+     * @param ajaxAware distinguishes between &lt;ft:repeater-widget&gt; and &lt;ft:repeater&gt;.
+     * @return true if the repeater template is to be executed
+     * @throws SAXException
+     */
+    public boolean pushRepeater(String path, boolean ajaxAware) throws SAXException {
+        if (!ajaxAware && this.ajaxTemplate) {
+            throw new IllegalStateException("Cannot use <ft:repeater-widget> in an
Ajax form");
+        }
         boolean result = pushWidget(path, true);
         if (result && !(peekWidget() instanceof Repeater)) {
             throw new IllegalArgumentException("Widget " + peekWidget() + " is not a repeater");
@@ -308,10 +319,6 @@
     }
 
     private static final String VALIDATION_ERROR = "validation-error";
-
-    public void generateRepeaterValidationMessage(Widget widget, String id) throws SAXException
{
-        getRepeater(widget, id).generateValidationMessage(this.cocoonConsumer);
-    }
 
     public void generateValidationError(ValidationError error) throws SAXException {
         // Needs to be buffered

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/jx-macros.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/jx-macros.xml?rev=307119&r1=307118&r2=307119&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/jx-macros.xml (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/jx-macros.xml Fri Oct
 7 06:28:45 2005
@@ -79,21 +79,12 @@
     </jx:macro>
 
     <!--
-        ft:repeater-validation-error
-    -->
-    <jx:macro name="repeater-validation-message" targetNamespace="http://apache.org/cocoon/forms/1.0#template">
-      <jx:parameter name="id"/>
-
-      <jx:set var="cformsDummy" value="${cformsHelper.generateRepeaterValidationMessage(widget,
id)}"/>
-    </jx:macro>
-
-    <!--
-        ft:repeater-widget
+        ft:repeater-widget, the old non-ajax capable way
     -->
     <jx:macro name="repeater-widget" targetNamespace="http://apache.org/cocoon/forms/1.0#template">
       <jx:parameter name="id"/>
 
-      <jx:if test="${cformsHelper.pushRepeater(id)}">
+      <jx:if test="${cformsHelper.pushRepeater(id, false)}">
         <jx:set var="repeater" value="${cformsHelper.peekWidget()}"/>
         <jx:forEach varStatus="repeaterLoop" begin="0" end="${repeater.getSize() - 1}">
           <jx:if test="${cformsHelper.pushContainer(java.lang.Integer.toString(repeaterLoop.index))}">
@@ -220,7 +211,7 @@
     
     <jx:macro name="repeater" targetNamespace="http://apache.org/cocoon/forms/1.0#template">
       <jx:parameter name="id"/>
-      <jx:if test="${cformsHelper.pushRepeater(id)}">
+      <jx:if test="${cformsHelper.pushRepeater(id, true)}">
         <jx:set var="repeater" value="${cformsHelper.peekWidget()}"/>
         <jx:set var="widget" value="${cformsHelper.peekWidget()}"/>
         <jx:evalBody/>

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-calendar-styling.xsl
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-calendar-styling.xsl?rev=307119&r1=307118&r2=307119&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-calendar-styling.xsl
(original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-calendar-styling.xsl
Fri Oct  7 06:28:45 2005
@@ -49,8 +49,8 @@
       |   selection lists must be excluded here
       +-->
   <xsl:template match="fi:field[fi:styling/@type='date'] |
-                       fi:field[not(fi:styling/@type)][fi:datatype[@type='date'][fi:convertor/@variant='date']][not(fi:selection-list)]
|
-                       fi:aggregatefield[not(fi:styling/@type)][fi:datatype[@type='date'][fi:convertor/@variant='date']][not(fi:selection-list)]
+                       fi:field[fi:datatype[@type='date'][fi:convertor/@variant='date']][not(fi:styling/@type)][not(fi:selection-list)]
|
+                       fi:aggregatefield[fi:datatype[@type='date'][fi:convertor/@variant='date']][not(fi:styling/@type)][not(fi:selection-list)]
                        ">
     <xsl:variable name="id" select="generate-id()"/>
     
@@ -64,26 +64,33 @@
     </xsl:variable>
     
     <span id="{@id}">
-      <!-- regular input -->
-      <input id="{@id}" name="{@id}" value="{fi:value}" title="{normalize-space(fi:hint)}"
type="text">
-        <xsl:apply-templates select="." mode="styling"/>
-      </input>
-    
-      <!-- calendar popup -->
       <xsl:choose>
-        <xsl:when test="@state = 'disabled'">
-          <img src="{$resources-uri}/img/cal.gif" alt="forms:calendar.alt" i18n:attr="alt"/>
+        <xsl:when test="@state = 'output'">
+          <xsl:value-of select="fi:value"/>
         </xsl:when>
         <xsl:otherwise>
-          <a href="#" name="{$id}" id="{$id}"
-             onclick="forms_calendar.select(forms_getForm(this)['{@id}'],'{$id}','{$format}');
return false;">
-            <img src="{$resources-uri}/img/cal.gif" alt="forms:calendar.alt" i18n:attr="alt"/>
-          </a>
-        </xsl:otherwise>
-      </xsl:choose>
-
-      <!-- common stuff -->
-      <xsl:apply-templates select="." mode="common"/>
+	      <!-- regular input -->
+	      <input id="{@id}" name="{@id}" value="{fi:value}" title="{normalize-space(fi:hint)}"
type="text">
+	        <xsl:apply-templates select="." mode="styling"/>
+	      </input>
+	    
+	      <!-- calendar popup -->
+	      <xsl:choose>
+	        <xsl:when test="@state = 'disabled'">
+	          <img src="{$resources-uri}/img/cal.gif" alt="forms:calendar.alt" i18n:attr="alt"/>
+	        </xsl:when>
+	        <xsl:otherwise>
+	          <a href="#" name="{$id}" id="{$id}"
+	             onclick="forms_calendar.select(forms_getForm(this)['{@id}'],'{$id}','{$format}');
return false;">
+	            <img src="{$resources-uri}/img/cal.gif" alt="forms:calendar.alt" i18n:attr="alt"/>
+	          </a>
+	        </xsl:otherwise>
+	      </xsl:choose>
+	
+	      <!-- common stuff -->
+	      <xsl:apply-templates select="." mode="common"/>
+	    </xsl:otherwise>
+	  </xsl:choose>
     </span>
   </xsl:template>
 

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-field-styling.xsl
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-field-styling.xsl?rev=307119&r1=307118&r2=307119&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-field-styling.xsl
(original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-field-styling.xsl
Fri Oct  7 06:28:45 2005
@@ -161,7 +161,7 @@
   <!--+
       |
       +-->
-  <xsl:template match="fi:validation-message|fi:repeater-validation-message">
+  <xsl:template match="fi:validation-message">
     <a href="#" class="forms-validation-message">
       <xsl:attribute name="onclick">
         <xsl:text>alert('</xsl:text>

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/transformation/EffectWidgetReplacingPipe.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/transformation/EffectWidgetReplacingPipe.java?rev=307119&r1=307118&r2=307119&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/transformation/EffectWidgetReplacingPipe.java
(original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/transformation/EffectWidgetReplacingPipe.java
Fri Oct  7 06:28:45 2005
@@ -79,7 +79,6 @@
     private static final String GROUP = "group";
     private static final String NEW = "new";
     private static final String REPEATER_SIZE = "repeater-size";
-    private static final String REPEATER_VALIDATION_MESSAGE = "repeater-validation-message";
     private static final String REPEATER_WIDGET = "repeater-widget";
     private static final String REPEATER_WIDGET_LABEL = "repeater-widget-label";
     private static final String STRUCT = "struct";
@@ -100,7 +99,6 @@
     private final NestedHandler                    hNested          = new NestedHandler();
     private final NewHandler                       hNew             = new NewHandler();
     private final RepeaterSizeHandler              hRepeaterSize    = new RepeaterSizeHandler();
-    private final RepeaterValidationMessageHandler hRepeaterValidationMessage = new RepeaterValidationMessageHandler();
     private final RepeaterWidgetHandler            hRepeaterWidget  = new RepeaterWidgetHandler();
     private final RepeaterWidgetLabelHandler       hRepeaterWidgetLabel = new RepeaterWidgetLabelHandler();
     private final SkipHandler                      hSkip            = new SkipHandler();
@@ -542,23 +540,6 @@
         throws SAXException {
             setTypedWidget(loc, attrs, Repeater.class, "repeater");
             ((Repeater) widget).generateSize(getContentHandler());
-            widget = null;
-            return this;
-        }
-
-        public void endElement(String uri, String loc, String raw)
-        throws SAXException {
-        }
-    }
-
-    /**
-     * Handles <code>ft:repeater-validation-message</code> element.
-     */
-    protected class RepeaterValidationMessageHandler extends ErrorHandler {
-        public Handler startElement(String uri, String loc, String raw, Attributes attrs)
-        throws SAXException {
-            setTypedWidget(loc, attrs, Repeater.class, "repeater");
-            ((Repeater) widget).generateValidationMessage(getContentHandler());
             widget = null;
             return this;
         }



Mime
View raw message