cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r330531 - in /cocoon: blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/ blocks/forms/trunk/java/org/apache/cocoon/forms/resources/ blocks/forms/trunk/java/org/apache/cocoon/forms/resources/js/ branches/BRANCH_2_1_X/
Date Thu, 03 Nov 2005 12:24:19 GMT
Author: sylvain
Date: Thu Nov  3 04:24:03 2005
New Revision: 330531

URL: http://svn.apache.org/viewcvs?rev=330531&view=rev
Log:
Add the convention of appending ':' and a name to a widget's id for ids of generated elements

Modified:
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-advanced-field-styling.xsl
    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/resources/js/forms-lib.js
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java?rev=330531&r1=330530&r2=330531&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java
(original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java
Thu Nov  3 04:24:03 2005
@@ -112,6 +112,10 @@
                 throw new Exception("A widget name cannot contain '.' or '/' as this conflicts
with widget paths, at " +
                         DomHelper.getLocation(widgetElement));
             }
+            if (id.indexOf(':') != -1) {
+                throw new Exception("A widget name cannot contain ':' as this conflicts with
library prefixes, at " +
+                        DomHelper.getLocation(widgetElement));
+            }
             widgetDefinition.setId(id);
         }
 

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-advanced-field-styling.xsl
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-advanced-field-styling.xsl?rev=330531&r1=330530&r2=330531&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-advanced-field-styling.xsl
(original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-advanced-field-styling.xsl
Thu Nov  3 04:24:03 2005
@@ -72,7 +72,7 @@
     	<span style="float:right"><a href="#" onClick="document.getElementById('{$id}').style.visibility
= 'hidden';return false;"><img align="top" alt="close" src="{$resources-uri}/forms/img/close.gif"
height="6" width="6"/></a></span>
       <xsl:apply-templates select="node()"/>
     </div>
-    <a id="{$id}-a" href="#" onclick="forms_createPopupWindow('{$id}').showPopup('{$id}-a');return
false;">
+    <a id="{$id}:a" href="#" onclick="forms_createPopupWindow('{$id}').showPopup('{$id}:a');return
false;">
       <!-- TODO: i18n key for helppopup -->
       <img src="{$resources-uri}/forms/img/help.gif" alt="helppopup"/>
     </a>
@@ -153,7 +153,7 @@
           </td>
           <td>
             <!-- select for the selected values -->
-            <select id="{@id}-input" name="{@id}" multiple="multiple"
+            <select id="{@id}:input" name="{@id}" multiple="multiple"
                     ondblclick="opt{generate-id()}.forms_transferLeft()" >
               <xsl:apply-templates select="." mode="styling"/>
               <xsl:for-each select="fi:selection-list/fi:item">
@@ -184,7 +184,7 @@
     <xsl:variable name="values" select="fi:values/fi:value/text()"/>
 
     <div id="{$id}">
-      <input name="{$id}.entry" id="{$id}.entry">
+      <input name="{$id}:entry" id="{$id}:entry">
         <xsl:if test="fi:styling/@size">
           <xsl:attribute name="size"><xsl:value-of select="fi:styling/@size"/></xsl:attribute>
         </xsl:if>
@@ -193,7 +193,7 @@
       <table>
         <tr>
           <td>
-            <select name="{$id}" id="{$id}-input" size="5" multiple="multiple" style="width:
150px">
+            <select name="{$id}" id="{$id}:input" size="5" multiple="multiple" style="width:
150px">
               <xsl:for-each select="$values">
                 <option value="{.}"><xsl:value-of select="."/></option>
               </xsl:for-each>
@@ -202,15 +202,15 @@
           <td>
             <!-- strangely, IE adds an extra blank line if there only a button on a line.
So we surround it with nbsp -->
             <xsl:text>&#160;</xsl:text>
-            <input type="image" id="{$id}.delete" src="{$resources-uri}/forms/img/delete.gif"/>
+            <input type="image" id="{$id}:delete" src="{$resources-uri}/forms/img/delete.gif"/>
             <xsl:text>&#160;</xsl:text>
             <br/>
             <xsl:text>&#160;</xsl:text>
-            <input type="image" id="{$id}.up" src="{$resources-uri}/forms/img/move_up.gif"/>
+            <input type="image" id="{$id}:up" src="{$resources-uri}/forms/img/move_up.gif"/>
             <xsl:text>&#160;</xsl:text>
             <br/>
             <xsl:text>&#160;</xsl:text>
-            <input type="image" id="{$id}.down" src="{$resources-uri}/forms/img/move_down.gif"/>
+            <input type="image" id="{$id}:down" src="{$resources-uri}/forms/img/move_down.gif"/>
             <xsl:text>&#160;</xsl:text>
             <br/>
             <xsl:apply-templates select="." mode="common"/>

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=330531&r1=330530&r2=330531&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
Thu Nov  3 04:24:03 2005
@@ -70,7 +70,7 @@
         </xsl:when>
         <xsl:otherwise>
 	      <!-- regular input -->
-	      <input id="{@id}-input" name="{@id}" value="{fi:value}" title="{normalize-space(fi:hint)}"
type="text">
+	      <input id="{@id}:input" name="{@id}" value="{fi:value}" title="{normalize-space(fi:hint)}"
type="text">
 	        <xsl:apply-templates select="." mode="styling"/>
 	      </input>
 	    

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=330531&r1=330530&r2=330531&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
Thu Nov  3 04:24:03 2005
@@ -53,8 +53,8 @@
         <img src="captcha-{fi:captcha-image/@id}.jpg" style="vertical-align:middle"/>
         <xsl:text> </xsl:text>
       </xsl:if>
-      <!--  @id-input is what labels point to -->
-      <input name="{@id}" id="{@id}-input" value="{fi:value}" title="{fi:hint}" type="text">
+      <!--  @id:input is what labels point to -->
+      <input name="{@id}" id="{@id}:input" value="{fi:value}" title="{fi:hint}" type="text">
         <xsl:apply-templates select="." mode="styling"/>
       </input>
       <xsl:apply-templates select="." mode="common"/>
@@ -201,9 +201,10 @@
       <xsl:when test="$vertical">
         <table id="{$id}" cellpadding="0" cellspacing="0" border="0" title="{fi:hint}">
           <xsl:for-each select="fi:selection-list/fi:item">
+            <xsl:variable name="item-id" select="concat($id, ':', position())"/>
             <tr>
               <td>
-                <input type="radio" id="{generate-id()}" name="{$id}" value="{@value}">
+                <input type="radio" id="{$item-id}" name="{$id}" value="{@value}">
                   <xsl:if test="@value = $value">
                     <xsl:attribute name="checked">checked</xsl:attribute>
                   </xsl:if>
@@ -212,7 +213,7 @@
               </td>
               <td>
                 <xsl:apply-templates select="." mode="label">
-                  <xsl:with-param name="id" select="generate-id()"/>
+                  <xsl:with-param name="id" select="$item-id"/>
                 </xsl:apply-templates>
               </td>
               <xsl:if test="position() = 1">
@@ -227,14 +228,15 @@
       <xsl:otherwise>
         <span id="{$id}" title="{fi:hint}">
           <xsl:for-each select="fi:selection-list/fi:item">
-            <input type="radio" id="{generate-id()}" name="{$id}" value="{@value}">
+            <xsl:variable name="item-id" select="concat($id, ':', position())"/>
+            <input type="radio" id="{$item-id}" name="{$id}" value="{@value}">
               <xsl:if test="@value = $value">
                 <xsl:attribute name="checked">checked</xsl:attribute>
               </xsl:if>
               <xsl:apply-templates select="../.." mode="styling"/>
             </input>
             <xsl:apply-templates select="." mode="label">
-              <xsl:with-param name="id" select="generate-id()"/>
+              <xsl:with-param name="id" select="$item-id"/>
             </xsl:apply-templates>
           </xsl:for-each>
           <xsl:apply-templates select="." mode="common"/>
@@ -255,7 +257,7 @@
 
     <!-- dropdown or listbox -->
     <span id="{@id}">
-      <select title="{fi:hint}" id="{@id}-input" name="{@id}">
+      <select title="{fi:hint}" id="{@id}:input" name="{@id}">
         <xsl:apply-templates select="." mode="styling"/>
         <xsl:for-each select="fi:selection-list/fi:item">
           <option value="{@value}">
@@ -275,7 +277,7 @@
       +-->
   <xsl:template match="fi:field[fi:styling/@type='textarea']">
     <span id="{@id}">
-      <textarea id="{@id}-input" name="{@id}" title="{fi:hint}">
+      <textarea id="{@id}:input" name="{@id}" title="{fi:hint}">
         <xsl:apply-templates select="." mode="styling"/>
         <!-- remove carriage-returns (occurs on certain versions of IE and doubles linebreaks
at each submit) -->
         <xsl:copy-of select="translate(fi:value/node(), '&#13;', '')"/>
@@ -318,7 +320,7 @@
     <xsl:variable name="resolvedId">
       <xsl:choose>
         <xsl:when test="$id != ''"><xsl:value-of select="$id"/></xsl:when>
-        <xsl:otherwise><xsl:value-of select="concat(@id, '-input')"/></xsl:otherwise>
+        <xsl:otherwise><xsl:value-of select="concat(@id, ':input')"/></xsl:otherwise>
       </xsl:choose>
     </xsl:variable>
 
@@ -341,7 +343,7 @@
       +-->
   <xsl:template match="fi:booleanfield">
     <span id="{@id}">
-      <input id="{@id}-input" type="checkbox" value="{@true-value}" name="{@id}" title="{fi:hint}">
+      <input id="{@id}:input" type="checkbox" value="{@true-value}" name="{@id}" title="{fi:hint}">
         <xsl:apply-templates select="." mode="styling"/>
         <xsl:choose>
           <xsl:when test="./fi:styling[@type='hidden']">
@@ -415,13 +417,14 @@
     <span id="{@id}" title="{fi:hint}">
       <xsl:for-each select="fi:selection-list/fi:item">
         <xsl:variable name="value" select="@value"/>
-        <input id="{generate-id()}" type="checkbox" value="{@value}" name="{$id}">
+        <xsl:variable name="item-id" select="concat($id, ':', position())"/>
+        <input id="{$item-id}" type="checkbox" value="{@value}" name="{$id}">
           <xsl:if test="$values[. = $value]">
             <xsl:attribute name="checked">checked</xsl:attribute>
           </xsl:if>
         </input>
         <xsl:apply-templates select="." mode="label">
-          <xsl:with-param name="id" select="generate-id()"/>
+          <xsl:with-param name="id" select="$item-id"/>
         </xsl:apply-templates>
         <br/>
       </xsl:for-each>
@@ -437,7 +440,7 @@
     <xsl:variable name="values" select="fi:values/fi:value/text()"/>
 
     <span id="{@id}" title="{fi:hint}">
-      <select id="{@id}-input" name="{$id}" multiple="multiple">
+      <select id="{@id}:input" name="{$id}" multiple="multiple">
         <xsl:apply-templates select="." mode="styling"/>
         <xsl:for-each select="fi:selection-list/fi:item">
           <xsl:variable name="value" select="@value"/>
@@ -479,10 +482,10 @@
             <xsl:text>[</xsl:text>
             <xsl:value-of select="fi:value"/>
             <xsl:text>] </xsl:text>
-            <input type="button" id="{@id}-input" name="{@id}" value="..." onclick="forms_submitForm(this)"/>
+            <input type="button" id="{@id}:input" name="{@id}" value="..." onclick="forms_submitForm(this)"/>
         </xsl:when>
         <xsl:otherwise>
-          <input type="file" id="{@id}-input" name="{@id}" title="{fi:hint}" accept="{@mime-types}">
+          <input type="file" id="{@id}:input" name="{@id}" title="{fi:hint}" accept="{@mime-types}">
             <xsl:apply-templates select="." mode="styling"/>
           </input>
         </xsl:otherwise>
@@ -599,7 +602,7 @@
 
   <xsl:template match="fi:aggregatefield">
     <span id="{@id}">
-      <input id="{@id}-input" name="{@id}" value="{fi:value}" title="{fi:hint}">
+      <input id="{@id}:input" name="{@id}" value="{fi:value}" title="{fi:hint}">
         <xsl:apply-templates select="." mode="styling"/>
       </input>
       <xsl:apply-templates select="." mode="common"/>

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/js/forms-lib.js
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/js/forms-lib.js?rev=330531&r1=330530&r2=330531&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/js/forms-lib.js (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/js/forms-lib.js Thu Nov
 3 04:24:03 2005
@@ -206,20 +206,20 @@
  * FormsMultiValueEditor is the implementation of the free-form multivalue field editor.
  */
 function FormsMultiValueEditor(id) {
-    this.select = document.getElementById(id + "-input");
-    this.entry = document.getElementById(id + ".entry");
+    this.select = document.getElementById(id + ":input");
+    this.entry = document.getElementById(id + ":entry");
     var self = this;
     this.entry.onkeypress = function(event) { return self.processInputKey(event); };
     this.select.onkeydown = function(event) { return self.processSelectKey(event); };
     this.select.onchange = function(event) { return self.processSelectChange(event); };
 
-    var deleteEl = document.getElementById(id + ".delete");
+    var deleteEl = document.getElementById(id + ":delete");
     deleteEl.onclick = function() { self.deleteValues(); return false; };
 
-    var upEl = document.getElementById(id + ".up");
+    var upEl = document.getElementById(id + ":up");
     upEl.onclick = function() { self.moveUp(); return false; };
 
-    var downEl = document.getElementById(id + ".down");
+    var downEl = document.getElementById(id + ":down");
     downEl.onclick = function() { self.moveDown(); return false; };
 
     var onsubmitHandler = new Object();

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?rev=330531&r1=330530&r2=330531&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Thu Nov  3 04:24:03 2005
@@ -183,6 +183,13 @@
              more necessary. For those cases where a field with event listeners should not
be automatically
              submitted, set <code>submit-on-change</code> to <code>false</code>.
          </li>
+         <li>Introduce a naming convention for stylesheet-generated IDs: they should
all start with the
+             widget's ID followed by a ":" and a name. The use of ":", which is forbidden
in widget names,
+             avoids conflicts with other widgets in the form. All stylesheets have been updated
to this convention.<br/>
+             This change can break applications that use document.getElementById() to access
some of the generated
+             elements (notably "foo-input" that's used for the &lt;input&gt; of the
"foo" widget), but this notation is now
+             a public contract that will be taken care of in the future.
+         </li>
          <li>Along with field, aggregatefield and booleanfield, you can now add value-changed
listeners on output
              and upload widgets.
          </li>



Mime
View raw message