You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by lt...@apache.org on 2006/10/25 22:07:44 UTC

svn commit: r467749 - /cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/forms-field-styling.xsl

Author: ltrieloff
Date: Wed Oct 25 13:07:43 2006
New Revision: 467749

URL: http://svn.apache.org/viewvc?view=rev&rev=467749
Log:
Update forms to include id attribute of a form group into a container element if not already existing. Fixes COCOON-1944 by Rob Berens

Modified:
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/forms-field-styling.xsl

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/forms-field-styling.xsl
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/forms-field-styling.xsl?view=diff&rev=467749&r1=467748&r2=467749
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/forms-field-styling.xsl (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/forms-field-styling.xsl Wed Oct 25 13:07:43 2006
@@ -735,9 +735,27 @@
 
   <!--+
       | fi:group - has no visual representation by default
+      | If the fi:group contains an id and has only one child that is not in the fi: namespace,
+      | then copy the id to the child. This is needed for ajax when grouping is just used to group
+      | widgets. 
       +-->
+  <xsl:template match="fi:group[@id and count(*) = 1 and not(fi:*)]">
+    <xsl:apply-templates mode="copy-parent-id"/>
+  </xsl:template>
+
   <xsl:template match="fi:group">
     <xsl:apply-templates/>
+  </xsl:template>
+
+  <xsl:template match="*" mode="copy-parent-id">
+    <xsl:copy>
+      <!-- do not override id if already specified, else use parent id -->
+      <xsl:if test="not(@id)">
+        <xsl:attribute name="id"><xsl:value-of select="../@id"/></xsl:attribute>
+      </xsl:if>
+      <xsl:copy-of select="@*"/>
+      <xsl:apply-templates/>
+    </xsl:copy>
   </xsl:template>
 
   <xsl:template match="@*|node()" priority="-1">



Re: svn commit: r467749 - /cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/forms-field-styling.xsl

Posted by Lars Trieloff <la...@trieloff.net>.
Hi Jörg,

Am 25.10.2006 um 23:10 schrieb Joerg Heinicke:

> On 25.10.2006 22:07, ltrieloff@apache.org wrote:
>
>> +  <xsl:template match="*" mode="copy-parent-id">
>> +    <xsl:copy>
>> +      <!-- do not override id if already specified, else use  
>> parent id -->
>> +      <xsl:if test="not(@id)">
>> +        <xsl:attribute name="id"><xsl:value-of select="../@id"/></ 
>> xsl:attribute>
>> +      </xsl:if>
>> +      <xsl:copy-of select="@*"/>
>
> This check is not necessary, the orignal version works. The reason  
> is, that the potential attribute on the currently processed element  
> overwrites the other one, as <xsl:copy-of select="@*"/> is applied  
> after <xsl:attribute name="id">.

Thanks for the hint, I did not notice this, but reverted it to the  
original state now.

>
> But something more general: This patch looks very specific for a  
> maybe much more generic problem. This is just a feeling ... have  
> not been working with CForms since 2 years and never with its Ajax  
> functionality. What's the actual root cause?

The main problem is that Cocoon-Ajax sends an update-command to the  
browser after deactivating or activating a fi:group programatically.  
This update-command works on a single HTML element that needs an ID  
to be identified.
Forms that use ft:group with AJAX need to wrap everything contained  
in the group into a single HTML element to be able to recieve  
updates. If this element does not include an ID attribute, updating  
does not work either, because the target of the operation cannot be  
determined, so this stylesheet fix just copies the ID of the  
enclosing fi:group.

Lars

--
Lars Trieloff
visit http://www.mindquarry.com/




Re: svn commit: r467749 - /cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/forms-field-styling.xsl

Posted by Joerg Heinicke <jo...@gmx.de>.
On 25.10.2006 22:07, ltrieloff@apache.org wrote:

> +  <xsl:template match="*" mode="copy-parent-id">
> +    <xsl:copy>
> +      <!-- do not override id if already specified, else use parent id -->
> +      <xsl:if test="not(@id)">
> +        <xsl:attribute name="id"><xsl:value-of select="../@id"/></xsl:attribute>
> +      </xsl:if>
> +      <xsl:copy-of select="@*"/>

This check is not necessary, the orignal version works. The reason is, 
that the potential attribute on the currently processed element 
overwrites the other one, as <xsl:copy-of select="@*"/> is applied after 
<xsl:attribute name="id">.

But something more general: This patch looks very specific for a maybe 
much more generic problem. This is just a feeling ... have not been 
working with CForms since 2 years and never with its Ajax functionality. 
What's the actual root cause?

Jörg