cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas Duroc <nicolas.du...@free.fr>
Subject Ajax & add-row
Date Tue, 25 Jul 2006 15:19:40 GMT
Hi,

I have a binding form to edit XML files, and I would like to propose to users 
the possibility to add elements (XML node), I tried to use ajax and the 
repeater-action to add node. The  mecanism works, but not with ajax events. 
The page is entirely reloaded when I click on the "add" bouton, and the URL 
page changes (with id continuation).

I enabled ajax (="true") in the form-template. In the sitemap, there is the 
pattern using "jx" generate. I really don't know where the miss is :/

here is a part of my binding xml file :
...
<fb:repeater id="essais" parent-path="." row-path="essai">
    <fb:on-bind>
        <fb:value id="date" path="date" />
        <fb:value id="heure" path="heure" />
        <fb:value id="lieu" path="lieu" />
        <fb:value id="Nom" path="nom" />
    </fb:on-bind>
    <fb:on-insert-row>
        <fb:insert-node>
            <essai>
                <date></date>
                <heure></heure>
                <lieu></lieu>
                <nom></nom>
            </essai>
        </fb:insert-node>
    </fb:on-insert-row>
</fb:repeater>
...

the model xml file :
...
<fd:repeater id="matchs">
    <fd:widgets>
        <fd:booleanfield id="select" />
        <fd:field id="date">
            <fd:label>Date</fd:label>
            <fd:datatype base="string" />
        </fd:field>
        <fd:field id="heure">
            <fd:label>Heure</fd:label>
            <fd:datatype base="string" />
        </fd:field>
        <fd:field id="lieu">
            <fd:label>Lieu</fd:label>
            <fd:datatype base="string" />
        </fd:field>
        <fd:field id="receveur">
            <fd:label>Receveur</fd:label>
            <fd:datatype base="string" />
        </fd:field>
        <fd:field id="nom">
            <fd:label>nom</fd:label>
            <fd:datatype base="string" />
        </fd:field>
        <fd:field id="visiteur">
            <fd:label>Visiteur</fd:label>
            <fd:datatype base="string" />
        </fd:field>
        <fd:field id="score_visiteur">
            <fd:label>Score</fd:label>
            <fd:datatype base="string" />
        </fd:field>
    </fd:widgets>
</fd:repeater>
<fd:repeater-action id="addEssai" command="add-row" repeater="essais">
    <fd:label>Ajouter</fd:label>
</fd:repeater-action>
<fd:repeater-action id="remove" command="delete-rows" repeater="essais" 
select="select">
    <fd:label>Supprimer</fd:label>
</fd:repeater-action>
...

the sitemap : 
...
<map:match pattern="*-*-display-pipeline.jx">
    <map:generate type="jx" src="/{1}/{2}_template.xml" />
    <map:transform type="browser-update"/>
    <map:transform type="forms" label="content1"/>
    <map:transform type="i18n">
        <!--map:parameter name="locale" value="en-US"/-->
    </map:transform>
    <map:call resource="simple-page2html">
        <map:parameter name="file" value="/{1}/{2}_template.xml"/>
    </map:call>
    <map:transform src="resources/forms-samples-styling.xsl">
        <map:parameter name="resources-uri" 
value="{request:contextPath}/_cocoon/resources"/>
    </map:transform>
    <map:select type="ajax-request">
        <map:when test="true">
           <map:serialize type="xml"/>
        </map:when>
        <map:otherwise>
           <map:serialize type="html"/>
        </map:otherwise>
     </map:select>
</map:match>
...

and the template :
<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
      xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
      xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
    <jx:import uri="resource://org/apache/cocoon/forms/generation/jx-
macros.xml"/>
<ft:form-template action="#{$cocoon/continuation/id}.continue.form3" 
method="POST" ajax="true">
<ft:repeater id="essais">
    <ft:repeater-rows>
        <div>
            <table>
                <tr>
                    <td width="20px">
                        <ft:widget id="select"><fi:styling 
class="checkbox" /></ft:widget>
                    </td>
                    <th align="left"><ft:widget-label id="date" /> :</th>
                    <td><ft:widget id="date" /></td>
                </tr>
                <tr>
                    <th align="left"><ft:widget-label id="heure" /> :</th>
                    <td><ft:widget id="heure" /></td>
                </tr>
                <tr>
                    <th align="left"><ft:widget-label id="lieu" /> :</th>
                    <td><ft:widget id="lieu" /></td>
                </tr>
            </table>
            <br />
         </div>
    </ft:repeater-rows>
</ft:repeater>
<ft:widget id="addEssai">
    <fi:styling class="bouton"/>
</ft:widget>
<ft:widget id="removeEssai">
    <fi:styling class="bouton"/>
</ft:widget>


If anyone has an idea...

Thanks in advance,

Regards,

Nicolas Duroc


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


Mime
View raw message