cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kamal <bh...@tt.com.au>
Subject [2.2] CForms - div around group and other Cforms issues
Date Sun, 27 Apr 2008 08:29:59 GMT
Hi,
I have been struggling with CForms, trying to work out what I did wrong. 
I think I found a couple of bugs in CForms.

I have a form that dynamically reveal sets of fields based on whether a 
tick box has been checked. Because I was using a very old version of 
CForms (2.1.7), I couldn't use the group method, so I had to reveal/hide 
each field separately. I found out that this approach is not compatible 
with CForms + Ajax because the labels are not updated. Also, the Cocoon 
website says to put a div around all fields in a ft:group for Ajax. I 
did this, but it kept failing. I had a look at the code and I found this:

  <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="fi:group" mode="copy-parent-id">  
    <xsl:copy>
      <xsl:attribute name="id"><xsl:value-of 
select="../@id"/></xsl:attribute>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

I changed it to this:

  <!--+
      | 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>
      <xsl:attribute name="id"><xsl:value-of 
select="../@id"/></xsl:attribute>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

and it all works. Is my fix correct? If so, should I create a patch 
and/or Jira ticket?'

Also, the booleanfield no longer works the way it used to in 2.1. 
Namely, I used to be able to do this:

if (widget.value == 'false')
{
    // Do something.
}

Now, it is returning a Boolean object (maybe it always did, I don't 
know) and I now have to do this:

if (widget.value.toString().equals('false'))

Any thoughts? Is it a good idea to return a string instead?


Finally, my previous post (BTW, sorry for all the emails) mentioned 
javascript files that are missing/in the wrong spot. I had a look at the 
logs and these files are still being requested, but they are not 
impacting on the rendering of the page. However, for the life of me, I 
cannot find the references to these files on my page.

Also, I know we have an ongoing issue with tabs and validation errors 
not working. I was wondering about the rationale for not using 
bu:replace on the appropriate divs to fix these issues?

Thanks.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message