cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@s-und-n.de
Subject RE: Xhtml and Ajax...no go!!
Date Wed, 26 Jul 2006 09:28:26 GMT
Hi Andrew,

i had the same error and nearly got insane but now my app is running in
ajax - mode.

Here is what i did:

I added some js-files to my stylsheet:
 <script src="../_cocoon/resources/dojo/dojo.js" type="text/javascript"/>
 <script src="../_cocoon/resources/ajax/cocoon.js" type="text/javascript"/>
 <script src="../_cocoon/resources/forms/js/forms-lib.js" type=
"text/javascript"/>
 <script type="text/javascript">
       dojo.addOnLoad(forms_onload);
       dojo.require("cocoon.forms.*");
</script>

xsl:template match="fi:form-template|fi:form-generated">
    <form>
      <xsl:copy-of select="@*"/>
        <xsl:choose>
        <xsl:when test="@ajax = 'true'">
          <xsl:attribute name="dojoType">CFormsForm</xsl:attribute>
          <xsl:if test="@ajax = 'true'">
            <script type="text/javascript">cocoon.forms.ajax = true;</
script>
          </xsl:if>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="onsubmit">forms_onsubmit(); <xsl:value-of
select="@onsubmit"/></xsl:attribute>
        </xsl:otherwise>
      </xsl:choose>
      <div><input type="hidden" name="forms_submit_id"/></div>
      <xsl:apply-templates/>

      <!-- TODO: consider putting this in the xml stream from the
generator? -->
      <xsl:if test="self::fi:form-generated">
        <input type="submit"/>
      </xsl:if>
    </form>
  </xsl:template>


I also addes some code to the global sitemap.xmap:
1. a new selector:
      <map:selector logger="sitemap.selector.resource-exists"
name="resource-exists"
src="org.apache.cocoon.selection.ResourceExistsSelector"/>

2. a new match in the pipeline - area:
      <map:match pattern="_cocoon/resources/*/**">
                        <map:select type="resource-exists">
                              <map:when test="resources/{1}/{2}">
                                    <map:read src="resources/{1}/{2}"/>
                              </map:when>
                              <map:otherwise>
                                    <!-- get the files directly from the
*.jar file if resource does not exsist -->
                                    <map:read
src="resource://org/apache/cocoon/{1}/resources/{2}"/>
                              </map:otherwise>
                        </map:select>
      </map:match>



Hope that will help you.

Freundliche Grüße / With kind regards
Fabian Hagen

S&N AG
Klingenderstr. 5
D 33100 Paderborn

voice  +49 5251/1581- 0
fax    +49 5251/1581-71
eMail  fhagen@s-und-n.de
web    http://www.s-und-n.de


|---------+--------------------------->
|         |           Andrew          |
|         |           <andrewmadu@gmai|
|         |           l.com>          |
|         |                           |
|         |           26.07.2006 10:20|
|         |           Bitte antworten |
|         |           an users        |
|         |                           |
|---------+--------------------------->
  >-------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                      
                                        |
  |        An:      users@cocoon.apache.org                                              
                                        |
  |        Kopie:                                                                        
                                        |
  |        Thema:   Xhtml and Ajax...no go!!                                             
                                        |
  >-------------------------------------------------------------------------------------------------------------------------------|




Hi,
can someone please tell me why when setting ajax="true" in my CForm and
serializing the document as xhtml (Strict) the following line in the xhtml
output should break the page?:


<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE page PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
.........
<form action
="updateAccounts.kont" ajax="true" name=
"Form1" method="POST" dojoType="CFormsForm"
>
<script type=
"text/javascript">cocoon.forms.ajax = true;</script
>

What is it about the script line that xhtml does not like? My ajax map is:

                                                 <map:select
type="ajax-request">
                                                   <map:when test="true">

                                                     <map:serialize
type="xml"/>
                                                   </map:when>
                                                   <map:otherwise>
                                                     <map:serialize
type="xhtml"/>
                                                   </map:otherwise>
                                                 </map:select>


If I change the forms-styling-*.xsl document to an indclude js file.
<script src="" />, which contains that one line of js,
the page loads correctly but a js error is generated saying that 'cocoon'
is undefined. At this point, of course, no ajax works

and what you are left with on submitting a page is a full page reload!!

Any ideas anyone?

regards

Andrew



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


Mime
View raw message