You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2005/04/14 14:32:34 UTC
svn commit: r161264 [2/2] - in cocoon:
blocks/core/forms/trunk/java/org/apache/cocoon/forms/binding/
blocks/core/forms/trunk/java/org/apache/cocoon/forms/datatype/convertor/
blocks/core/forms/trunk/java/org/apache/cocoon/forms/datatype/typeimpl/
blocks/core/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/
blocks/core/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/v3/
blocks/core/forms/trunk/java/org/apache/cocoon/forms/formmodel/
blocks/core/forms/trunk/java/org/apache/cocoon/forms/generation/
blocks/core/forms/trunk/java/org/apache/cocoon/forms/resources/js/
blocks/core/forms/trunk/java/org/apache/cocoon/forms/samples/
blocks/core/forms/trunk/java/org/apache/cocoon/forms/util/
blocks/core/forms/trunk/samples/ blocks/core/forms/trunk/samples/flow/
blocks/core/forms/trunk/samples/forms/
blocks/core/forms/trunk/samples/forms/binding/
blocks/core/forms/trunk/samples/resources/
trunk/src/java/org/apache/cocoon/transformation/
Modified: cocoon/blocks/core/forms/trunk/samples/forms/tasktree_template.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/samples/forms/tasktree_template.xml?view=diff&r1=161263&r2=161264
==============================================================================
--- cocoon/blocks/core/forms/trunk/samples/forms/tasktree_template.xml (original)
+++ cocoon/blocks/core/forms/trunk/samples/forms/tasktree_template.xml Thu Apr 14 05:32:26 2005
@@ -65,7 +65,7 @@
</style>
<content>
- <ft:form-template action="#{$cocoon/continuation/id}.continue" method="POST">
+ <ft:form-template action="#{$cocoon/continuation/id}.continue" method="POST" ajax="true">
<ft:class id="task-class">
<div class="section">
@@ -90,20 +90,22 @@
<ft:class id="tasklist-class">
<!-- Show the "Add subtask" button only if there are currently no subtasks.
If there are some, more subtasks can be added using the "+" button -->
- <jx:choose>
- <jx:when test="${widget.getChild('tasks').getSize() > 0}">
- <ft:repeater-widget id="tasks">
- <!-- recurse -->
- <ft:new id="task-class"/>
+ <ft:repeater id="tasks">
+ <jx:choose>
+ <jx:when test="${repeater.getSize() > 0}">
+ <ft:repeater-rows>
+ <!-- recurse -->
+ <ft:new id="task-class"/>
- </ft:repeater-widget>
- </jx:when>
- <jx:otherwise>
+ </ft:repeater-rows>
+ </jx:when>
+ <jx:otherwise>
<ft:widget id="addsub">
- <fi:styling type="link"/>
- </ft:widget>
+ <fi:styling type="link"/>
+ </ft:widget>
</jx:otherwise>
</jx:choose>
+ </ft:repeater>
</ft:class>
Project name: <ft:widget id="name"/>
Modified: cocoon/blocks/core/forms/trunk/samples/resources/forms-advanced-field-styling.xsl
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/samples/resources/forms-advanced-field-styling.xsl?view=diff&r1=161263&r2=161264
==============================================================================
--- cocoon/blocks/core/forms/trunk/samples/resources/forms-advanced-field-styling.xsl (original)
+++ cocoon/blocks/core/forms/trunk/samples/resources/forms-advanced-field-styling.xsl Thu Apr 14 05:32:26 2005
@@ -90,7 +90,7 @@
<xsl:variable name="id" select="@id"/>
<xsl:variable name="values" select="fi:values/fi:value/text()"/>
- <div class="forms-doubleList" title="{fi:hint}">
+ <div id="{@id}" class="forms-doubleList" title="{fi:hint}">
<table>
<xsl:if test="fi:styling/fi:available-label|fi:styling/fi:selected-label">
<tr>
Modified: cocoon/blocks/core/forms/trunk/samples/resources/forms-calendar-styling.xsl
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/samples/resources/forms-calendar-styling.xsl?view=diff&r1=161263&r2=161264
==============================================================================
--- cocoon/blocks/core/forms/trunk/samples/resources/forms-calendar-styling.xsl (original)
+++ cocoon/blocks/core/forms/trunk/samples/resources/forms-calendar-styling.xsl Thu Apr 14 05:32:26 2005
@@ -65,28 +65,30 @@
</xsl:choose>
</xsl:variable>
- <!-- regular input -->
- <input id="{@id}" name="{@id}" value="{fi:value}" title="{normalize-space(fi:hint)}" type="text">
- <xsl:apply-templates select="." mode="styling"/>
- </input>
+ <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'">
- <!-- TODO: i18n key for @alt -->
- <img src="{$resources-uri}/img/cal.gif" alt="Calendar"/>
- </xsl:when>
- <xsl:otherwise>
- <a href="#" name="{$id}" id="{$id}"
- onclick="forms_calendar.select(forms_getForm(this)['{@id}'],'{$id}','{$format}'); return false;">
+ <!-- calendar popup -->
+ <xsl:choose>
+ <xsl:when test="@state = 'disabled'">
<!-- TODO: i18n key for @alt -->
<img src="{$resources-uri}/img/cal.gif" alt="Calendar"/>
- </a>
- </xsl:otherwise>
- </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <a href="#" name="{$id}" id="{$id}"
+ onclick="forms_calendar.select(forms_getForm(this)['{@id}'],'{$id}','{$format}'); return false;">
+ <!-- TODO: i18n key for @alt -->
+ <img src="{$resources-uri}/img/cal.gif" alt="Calendar"/>
+ </a>
+ </xsl:otherwise>
+ </xsl:choose>
- <!-- common stuff -->
- <xsl:apply-templates select="." mode="common"/>
+ <!-- common stuff -->
+ <xsl:apply-templates select="." mode="common"/>
+ </span>
</xsl:template>
</xsl:stylesheet>
Modified: cocoon/blocks/core/forms/trunk/samples/resources/forms-field-styling.xsl
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/samples/resources/forms-field-styling.xsl?view=diff&r1=161263&r2=161264
==============================================================================
--- cocoon/blocks/core/forms/trunk/samples/resources/forms-field-styling.xsl (original)
+++ cocoon/blocks/core/forms/trunk/samples/resources/forms-field-styling.xsl Thu Apr 14 05:32:26 2005
@@ -30,6 +30,7 @@
<xsl:template match="head" mode="forms-field">
<script src="{$resources-uri}/js/forms-lib.js" type="text/javascript"/>
+ <script src="{$resources-uri}/js/cforms.js" type="text/javascript"/>
<link rel="stylesheet" type="text/css" href="{$resources-uri}/css/forms.css"/>
</xsl:template>
@@ -48,17 +49,20 @@
| Generic fi:field : produce an <input>
+-->
<xsl:template match="fi:field">
- <input name="{@id}" id="{@id}" value="{fi:value}" title="{fi:hint}" type="text">
- <xsl:apply-templates select="." mode="styling"/>
- </input>
- <xsl:apply-templates select="." mode="common"/>
+ <span id="{@id}">
+ <!-- @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"/>
+ </span>
</xsl:template>
<!--+
| Field in "output" state: display its value
+-->
<xsl:template match="fi:field[@state='output']" priority="3">
- <xsl:value-of select="fi:value/node()"/>
+ <span id="{@id}"><xsl:value-of select="fi:value/node()"/></span>
</xsl:template>
<!--+
@@ -160,7 +164,7 @@
<xsl:variable name="vertical" select="string(fi:styling/@list-orientation) != 'horizontal'"/>
<xsl:choose>
<xsl:when test="$vertical">
- <table cellpadding="0" cellspacing="0" border="0" title="{fi:hint}">
+ <table id="{$id}" cellpadding="0" cellspacing="0" border="0" title="{fi:hint}">
<xsl:for-each select="fi:selection-list/fi:item">
<tr>
<td>
@@ -186,7 +190,7 @@
</table>
</xsl:when>
<xsl:otherwise>
- <span title="{fi:hint}">
+ <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:if test="@value = $value">
@@ -198,8 +202,8 @@
<xsl:with-param name="id" select="generate-id()"/>
</xsl:apply-templates>
</xsl:for-each>
+ <xsl:apply-templates select="." mode="common"/>
</span>
- <xsl:apply-templates select="." mode="common"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
@@ -215,18 +219,20 @@
<xsl:variable name="value" select="fi:value"/>
<!-- dropdown or listbox -->
- <select title="{fi:hint}" id="{@id}" name="{@id}">
- <xsl:apply-templates select="." mode="styling"/>
- <xsl:for-each select="fi:selection-list/fi:item">
- <option value="{@value}">
- <xsl:if test="@value = $value">
- <xsl:attribute name="selected">selected</xsl:attribute>
- </xsl:if>
- <xsl:copy-of select="fi:label/node()"/>
- </option>
- </xsl:for-each>
- </select>
- <xsl:apply-templates select="." mode="common"/>
+ <span id="{@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}">
+ <xsl:if test="@value = $value">
+ <xsl:attribute name="selected">selected</xsl:attribute>
+ </xsl:if>
+ <xsl:copy-of select="fi:label/node()"/>
+ </option>
+ </xsl:for-each>
+ </select>
+ <xsl:apply-templates select="." mode="common"/>
+ </span>
</xsl:template>
<!--+
@@ -235,33 +241,37 @@
<xsl:template match="fi:field[fi:selection-list][fi:styling/@type='output']" priority="3">
<xsl:variable name="value" select="fi:value"/>
<xsl:variable name="selected" select="fi:selection-list/fi:item[@value = $value]"/>
- <xsl:choose>
- <xsl:when test="$selected/fi:label">
- <xsl:copy-of select="$selected/fi:label/node()"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$value"/>
- </xsl:otherwise>
- </xsl:choose>
+ <span id="{@id}">
+ <xsl:choose>
+ <xsl:when test="$selected/fi:label">
+ <xsl:copy-of select="$selected/fi:label/node()"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$value"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </span>
</xsl:template>
<!--+
| fi:field with @type 'textarea'
+-->
<xsl:template match="fi:field[fi:styling/@type='textarea']">
- <textarea id="{@id}" 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(), ' ', '')"/>
- </textarea>
- <xsl:apply-templates select="." mode="common"/>
+ <span id="{@id}">
+ <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(), ' ', '')"/>
+ </textarea>
+ <xsl:apply-templates select="." mode="common"/>
+ </span>
</xsl:template>
<!--+
| fi:field with @type 'output' and fi:output are both rendered as text
+-->
<xsl:template match="fi:output | fi:field[fi:styling/@type='output']" priority="2">
- <xsl:copy-of select="fi:value/node()"/>
+ <span id="{@id}"><xsl:copy-of select="fi:value/node()"/></span>
</xsl:template>
<!--+
@@ -269,7 +279,7 @@
+-->
<xsl:template match="fi:*" mode="label">
<xsl:param name="id" select="@id"/>
- <label for="{$id}" title="{fi:hint}">
+ <label for="{$id}-input" title="{fi:hint}">
<xsl:copy-of select="fi:label/node()"/>
</label>
</xsl:template>
@@ -287,22 +297,24 @@
| the value and not the checked attribute
+-->
<xsl:template match="fi:booleanfield">
- <input id="{@id}" type="checkbox" value="true" name="{@id}" title="{fi:hint}">
- <xsl:apply-templates select="." mode="styling"/>
- <xsl:choose>
- <xsl:when test="./fi:styling[@type='hidden']">
- <xsl:if test="fi:value = 'false'">
- <xsl:attribute name="value">false</xsl:attribute>
- </xsl:if>
- </xsl:when>
- <xsl:otherwise>
- <xsl:if test="fi:value = 'true'">
- <xsl:attribute name="checked">checked</xsl:attribute>
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
- </input>
- <xsl:apply-templates select="." mode="common"/>
+ <span id="{@id}">
+ <input id="{@id}-input" type="checkbox" value="true" name="{@id}" title="{fi:hint}">
+ <xsl:apply-templates select="." mode="styling"/>
+ <xsl:choose>
+ <xsl:when test="./fi:styling[@type='hidden']">
+ <xsl:if test="fi:value = 'false'">
+ <xsl:attribute name="value">false</xsl:attribute>
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:if test="fi:value = 'true'">
+ <xsl:attribute name="checked">checked</xsl:attribute>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ </input>
+ <xsl:apply-templates select="." mode="common"/>
+ </span>
</xsl:template>
<!--+
@@ -310,7 +322,7 @@
| use text but avoids i18n problems related to hardcoding 'yes'/'no' or 'true'/'false'
+-->
<xsl:template match="fi:booleanfield[@state='output' or fi:styling/@type='output']" priority="3">
- <input type="checkbox" title="{fi:hint}" disabled="disabled">
+ <input id="{@id}" type="checkbox" title="{fi:hint}" disabled="disabled">
<xsl:if test="fi:value = 'true'">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
@@ -321,7 +333,7 @@
| fi:action
+-->
<xsl:template match="fi:action">
- <input id="{@id}" type="submit" name="{@id}" title="{fi:hint}">
+ <input id="{@id}" type="submit" name="{@id}" title="{fi:hint}" onclick="forms_submitForm(this, '{@id}'); return false">
<xsl:attribute name="value"><xsl:value-of select="fi:label/node()"/></xsl:attribute>
<xsl:apply-templates select="." mode="styling"/>
</input>
@@ -331,7 +343,7 @@
| fi:action, link-style
+-->
<xsl:template match="fi:action[fi:styling/@type = 'link']" priority="1">
- <a title="{fi:hint}" href="#" onclick="forms_submitForm(this, '{@id}'); return false">
+ <a id="{@id}" title="{fi:hint}" href="#" onclick="forms_submitForm(this, '{@id}'); return false">
<xsl:apply-templates select="." mode="styling"/>
<xsl:copy-of select="fi:label/node()"/>
</a>
@@ -357,7 +369,7 @@
<xsl:variable name="id" select="@id"/>
<xsl:variable name="values" select="fi:values/fi:value/text()"/>
- <span title="{fi:hint}">
+ <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}">
@@ -370,8 +382,8 @@
</xsl:apply-templates>
<br/>
</xsl:for-each>
+ <xsl:apply-templates select="." mode="common"/>
</span>
- <xsl:apply-templates select="." mode="common"/>
</xsl:template>
<!--+
@@ -381,8 +393,8 @@
<xsl:variable name="id" select="@id"/>
<xsl:variable name="values" select="fi:values/fi:value/text()"/>
- <span title="{fi:hint}">
- <select id="{@id}" name="{$id}" multiple="multiple">
+ <span id="{@id}" title="{fi:hint}">
+ <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"/>
@@ -394,8 +406,8 @@
</option>
</xsl:for-each>
</select>
+ <xsl:apply-templates select="." mode="common"/>
</span>
- <xsl:apply-templates select="." mode="common"/>
</xsl:template>
<!--+
@@ -403,50 +415,52 @@
+-->
<xsl:template match="fi:multivaluefield[@state='output']" priority="3">
<xsl:variable name="values" select="fi:values/fi:value/text()"/>
- <xsl:for-each select="fi:selection-list/fi:item">
- <xsl:variable name="value" select="@value"/>
- <xsl:if test="$values[. = $value]">
- <xsl:value-of select="fi:label/node()"/>
- </xsl:if>
- </xsl:for-each>
+ <span id="{@id}">
+ <xsl:for-each select="fi:selection-list/fi:item">
+ <xsl:variable name="value" select="@value"/>
+ <xsl:if test="$values[. = $value]">
+ <xsl:value-of select="fi:label/node()"/>
+ </xsl:if>
+ </xsl:for-each>
+ </span>
</xsl:template>
<!--+
| fi:upload
+-->
<xsl:template match="fi:upload">
- <xsl:choose>
- <xsl:when test="fi:value">
- <!-- Has a value (filename): display it with a change button -->
- <span title="{fi:hint}">
- <xsl:text>[</xsl:text>
- <xsl:value-of select="fi:value"/>
- <xsl:text>] </xsl:text>
- <input type="button" id="{@id}" name="{@id}" value="..." onclick="forms_submitForm(this)"/>
- </span>
- </xsl:when>
- <xsl:otherwise>
- <input type="file" id="{@id}" name="{@id}" title="{fi:hint}" accept="{@mime-types}">
- <xsl:apply-templates select="." mode="styling"/>
- </input>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:apply-templates select="." mode="common"/>
+ <span id="{@id}" title="{fi:hint}">
+ <xsl:choose>
+ <xsl:when test="fi:value">
+ <!-- Has a value (filename): display it with a change button -->
+ <xsl:text>[</xsl:text>
+ <xsl:value-of select="fi:value"/>
+ <xsl:text>] </xsl:text>
+ <input type="button" id="{@id}-input" name="{@id}-input" value="..." onclick="forms_submitForm(this)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <input type="file" id="{@id}-input" name="{@id}" title="{fi:hint}" accept="{@mime-types}">
+ <xsl:apply-templates select="." mode="styling"/>
+ </input>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:apply-templates select="." mode="common"/>`
+ </span>
</xsl:template>
<!--+
| fi:upload, output state
+-->
<xsl:template match="fi:upload[@state='output']" priority="3">
- <xsl:copy-of select="fi:value/node()"/>
+ <span id="{@id}"><xsl:copy-of select="fi:value/node()"/></span>
</xsl:template>
<!--+
| fi:repeater
+-->
<xsl:template match="fi:repeater">
- <input type="hidden" name="{@id}.size" value="{@size}"/>
- <table border="1">
+ <table id="{@id}" border="1">
+ <input type="hidden" name="{@id}.size" value="{@size}"/>
<tr>
<xsl:for-each select="fi:headings/fi:heading">
<th><xsl:value-of select="."/></th>
@@ -485,6 +499,9 @@
<xsl:attribute name="onsubmit">forms_onsubmit(); <xsl:value-of select="@onsubmit"/></xsl:attribute>
<!-- hidden field to store the submit id -->
<div><input type="hidden" name="forms_submit_id"/></div>
+ <xsl:if test="@ajax = 'true'">
+ <script script="text/javascript">CForms.ajax = true;</script>
+ </xsl:if>
<xsl:apply-templates/>
<!-- TODO: consider putting this in the xml stream from the generator? -->
@@ -530,62 +547,88 @@
</xsl:template>
<xsl:template match="fi:aggregatefield">
- <input id="{@id}" name="{@id}" value="{fi:value}" title="{fi:hint}">
- <xsl:apply-templates select="." mode="styling"/>
- </input>
- <xsl:apply-templates select="." mode="common"/>
+ <span id="{@id}">
+ <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"/>
+ </span>
</xsl:template>
<xsl:template match="fi:messages">
- <xsl:if test="fi:message">
- <xsl:apply-templates select="." mode="label"/>:
- <ul>
- <xsl:for-each select="fi:message">
- <li><xsl:apply-templates/></li>
- </xsl:for-each>
- </ul>
- </xsl:if>
+ <div id="{@id}">
+ <xsl:if test="fi:message">
+ <xsl:apply-templates select="." mode="label"/>:
+ <ul>
+ <xsl:for-each select="fi:message">
+ <li><xsl:apply-templates/></li>
+ </xsl:for-each>
+ </ul>
+ </xsl:if>
+ </div>
</xsl:template>
<xsl:template match="fi:validation-errors">
- <xsl:variable name="header">
- <xsl:choose>
- <xsl:when test="header">
- <xsl:copy-of select="header"/>
- </xsl:when>
- <xsl:otherwise>
- <p class="forms-validation-errors">The following errors have been detected (marked with !):</p>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="footer">
- <xsl:choose>
- <xsl:when test="footer">
- <xsl:copy-of select="footer"/>
- </xsl:when>
- <xsl:otherwise>
- <p class="forms-validation-errors">Please, correct them and re-submit the form.</p>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="messages" select="ancestor::fi:form-template//fi:validation-message"/>
- <xsl:if test="$messages">
- <xsl:copy-of select="$header"/>
- <ul>
- <xsl:for-each select="$messages">
- <li class="forms-validation-error">
- <xsl:variable name="label">
- <xsl:apply-templates select=".." mode="label"/>
- </xsl:variable>
- <xsl:if test="$label">
- <xsl:copy-of select="$label"/><xsl:text>: </xsl:text>
- </xsl:if>
- <xsl:value-of select="."/>
- </li>
- </xsl:for-each>
- </ul>
- <xsl:copy-of select="$footer"/>
- </xsl:if>
+ <div id="{@id}">
+ <xsl:variable name="header">
+ <xsl:choose>
+ <xsl:when test="header">
+ <xsl:copy-of select="header"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <p class="forms-validation-errors">The following errors have been detected (marked with !):</p>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="footer">
+ <xsl:choose>
+ <xsl:when test="footer">
+ <xsl:copy-of select="footer"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <p class="forms-validation-errors">Please, correct them and re-submit the form.</p>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="messages" select="ancestor::fi:form-template//fi:validation-message"/>
+ <xsl:if test="$messages">
+ <xsl:copy-of select="$header"/>
+ <ul>
+ <xsl:for-each select="$messages">
+ <li class="forms-validation-error">
+ <xsl:variable name="label">
+ <xsl:apply-templates select=".." mode="label"/>
+ </xsl:variable>
+ <xsl:if test="$label">
+ <xsl:copy-of select="$label"/><xsl:text>: </xsl:text>
+ </xsl:if>
+ <xsl:value-of select="."/>
+ </li>
+ </xsl:for-each>
+ </ul>
+ <xsl:copy-of select="$footer"/>
+ </xsl:if>
+ </div>
+ </xsl:template>
+
+ <xsl:template match="fi:union">
+ <div id="{@id}">
+ <xsl:apply-templates/>
+ </div>
+ </xsl:template>
+
+ <xsl:template match="fi:repeater-template">
+ <div id="{@id}">
+ <xsl:apply-templates/>
+ </div>
+ </xsl:template>
+
+ <!--+
+ | fi:placeholder - used to represent invisible widgets so that AJAX updates
+ | know where to insert the widget if it becomes visible
+ +-->
+ <xsl:template match="fi:placeholder">
+ <span id="{@id}"/>
</xsl:template>
<xsl:template match="@*|node()" priority="-1">
Modified: cocoon/blocks/core/forms/trunk/samples/resources/forms-page-styling.xsl
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/samples/resources/forms-page-styling.xsl?view=diff&r1=161263&r2=161264
==============================================================================
--- cocoon/blocks/core/forms/trunk/samples/resources/forms-page-styling.xsl (original)
+++ cocoon/blocks/core/forms/trunk/samples/resources/forms-page-styling.xsl Thu Apr 14 05:32:26 2005
@@ -141,7 +141,7 @@
<fieldset id="{$id}">
<legend title="{fi:hint}">
<xsl:apply-templates select="fi:label/node()"/>
- <select name="{$state-widget}" onchange="forms_showTab('{$id}', this.selectedIndex, {count(fi:items/*)}, '{$state-widget}')">
+ <select name="{$state-widget}" id="{$state-widget}" onchange="forms_showTab('{$id}', this.selectedIndex, {count(fi:items/*)}, '{$state-widget}')">
<xsl:for-each select="fi:items/fi:*">
<xsl:variable name="pos" select="position() - 1"/>
<option>
Modified: cocoon/blocks/core/forms/trunk/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/samples/sitemap.xmap?view=diff&r1=161263&r2=161264
==============================================================================
--- cocoon/blocks/core/forms/trunk/samples/sitemap.xmap (original)
+++ cocoon/blocks/core/forms/trunk/samples/sitemap.xmap Thu Apr 14 05:32:26 2005
@@ -20,6 +20,7 @@
<map:components>
<map:transformers default="xslt">
+ <map:transformer name="browser-update" src="org.apache.cocoon.transformation.BrowserUpdateTransformer"/>
<map:transformer name="i18n" src="org.apache.cocoon.transformation.I18nTransformer">
<catalogues default="other">
<catalogue id="other" name="OtherMessages" location="messages"/>
@@ -191,6 +192,7 @@
-->
<map:match pattern="*-display-pipeline.jx">
<map:generate type="jx" src="forms/{1}_template.xml" label="content1"/>
+ <map:transform type="browser-update"/>
<map:transform type="i18n">
<!--map:parameter name="locale" value="en-US"/-->
</map:transform>
@@ -198,7 +200,15 @@
<map:parameter name="file" value="forms/{1}_template.xml"/>
</map:call>
<map:transform src="resources/forms-samples-styling.xsl"/>
- <map:serialize/>
+ <map:select type="request-parameter">
+ <map:parameter name="parameter-name" value="cocoon-ajax"/>
+ <map:when test="true">
+ <map:serialize type="xml"/>
+ </map:when>
+ <map:otherwise>
+ <map:serialize type="html"/>
+ </map:otherwise>
+ </map:select>
</map:match>
<!--
@@ -431,6 +441,7 @@
</map:match>
<map:match pattern="resources/**">
+ <map:read src="/Users/sylvain/dev/apache.org/cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/{0}"/>
<map:read src="resource://org/apache/cocoon/forms/{0}"/>
</map:match>
Added: cocoon/trunk/src/java/org/apache/cocoon/transformation/BrowserUpdateTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/transformation/BrowserUpdateTransformer.java?view=auto&rev=161264
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/transformation/BrowserUpdateTransformer.java (added)
+++ cocoon/trunk/src/java/org/apache/cocoon/transformation/BrowserUpdateTransformer.java Thu Apr 14 05:32:26 2005
@@ -0,0 +1,108 @@
+package org.apache.cocoon.transformation;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.xml.AttributesImpl;
+import org.apache.cocoon.xml.RedundantNamespacesFilter;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+public class BrowserUpdateTransformer extends AbstractTransformer {
+
+ public static final String AJAXMODE_PARAM = "cocoon-ajax";
+
+ public static final String BU_NSURI = "http://apache.org/cocoon/browser-update/1.0";
+
+ private boolean ajaxMode = false;
+
+ private int replaceDepth = 0;
+
+ public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException {
+
+ Request request = ObjectModelHelper.getRequest(objectModel);
+ this.ajaxMode = request.getParameter(AJAXMODE_PARAM) != null;
+ }
+
+ public void startDocument() throws SAXException {
+
+ if (ajaxMode) {
+ // Add the namespace filter to our own output.
+ // This is needed as flattening bu:* elements can lead to some weird reordering of
+ // namespace declarations...
+ RedundantNamespacesFilter nsPipe = new RedundantNamespacesFilter();
+ if (this.xmlConsumer != null) {
+ nsPipe.setConsumer(this.xmlConsumer);
+ } else {
+ nsPipe.setContentHandler(this.contentHandler);
+ }
+ setConsumer(nsPipe);
+ }
+
+ super.startDocument();
+ if (ajaxMode) {
+ // Add a root element. The original one is very likely to be stripped
+ super.startPrefixMapping("bu", BU_NSURI);
+ super.startElement(BU_NSURI, "document", "bu:document", new AttributesImpl());
+ }
+ }
+
+ public void startPrefixMapping(String prefix, String uri) throws SAXException {
+ // always let them trough
+ super.startPrefixMapping(prefix, uri);
+ }
+
+ public void startElement(String uri, String loc, String raw, Attributes a) throws SAXException {
+ if (BU_NSURI.equals(uri) && "replace".equals(loc)) {
+ if (this.ajaxMode && this.replaceDepth == 0) {
+ // Pass this element through
+ super.startElement(uri, loc, raw, a);
+ }
+ replaceDepth++;
+ } else {
+ // Passthrough if not in ajax mode or if in a bu:replace
+ if (!this.ajaxMode || this.replaceDepth > 0) {
+ super.startElement(uri, loc, raw, a);
+ }
+ }
+ }
+
+ public void characters(char[] buffer, int offset, int len) throws SAXException {
+ if (!this.ajaxMode || this.replaceDepth > 0) {
+ super.characters(buffer, offset, len);
+ }
+ }
+
+ public void endElement(String uri, String loc, String raw) throws SAXException {
+ if (BU_NSURI.equals(uri) && "replace".equals(loc)) {
+ replaceDepth--;
+ if (this.ajaxMode && this.replaceDepth == 0) {
+ // Pass this element through
+ super.endElement(uri, loc, raw);
+ }
+ } else {
+ // Passthrough if not in ajax mode or if in a bu:replace
+ if (!this.ajaxMode || this.replaceDepth > 0) {
+ super.endElement(uri, loc, raw);
+ }
+ }
+ }
+
+ public void endPrefixMapping(String prefix) throws SAXException {
+ // always let them trough
+ super.endPrefixMapping(prefix);
+ }
+
+ public void endDocument() throws SAXException {
+ if (ajaxMode) {
+ super.endElement(BU_NSURI, "document", "bu:document");
+ super.endPrefixMapping("bu");
+ }
+ super.endDocument();
+ }
+}
Propchange: cocoon/trunk/src/java/org/apache/cocoon/transformation/BrowserUpdateTransformer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/src/java/org/apache/cocoon/transformation/BrowserUpdateTransformer.java
------------------------------------------------------------------------------
svn:keywords = Id