Guys,

I'm using cocoon 2.1.9-dev revision of today (after Antonio's change in cocoon-ajax.js and after Jorg revert of the I18N_NAMESPACE_URI move).

If I run the form below, I get a repeater with 11 rows, the last one is "dummy". If I submit, the last item is empty, i.e. the items are numbered 1 to 11, and nr 11 is there, but has a blank behind it.


Any ideas?

Bye, Helma

-----------------
Here's the code:

test.js
function test() {
        var language = _getLanguage();
        
        var dataBean = new Object();
        
        dataBean.name = "";

    dataBean.workshops = [
    {workshop: "MAS*" },
    {workshop: "3DE"  },
    {workshop: "ORI"  },
    {workshop: "PAA*" },
    {workshop: "MAP*" },
    {workshop: "KUS"  },
    {workshop: "OSB"  },
    {workshop: "DOO"  },
    {workshop: "KAD"  },
    {workshop: "PAT"  },
    {workshop: "dummy"}
    ];


        var formFileName = "test";
        var language = "nl";
        var formDisplay = language + "/" + formFileName + ".jx";
        var formResult = language + "/" + formFileName + "Result.jx";
        var formDef = FORMDIR + formFileName + "Def.xml";
        var formBind = FORMDIR + formFileName + "Bind.xml";

        var form = new Form(formDef);
        form.createBinding(formBind);
        form.load(dataBean);
        var success = form.showForm(formDisplay);
        if (success) {
                form.save(dataBean);
                var viewData = { beandata: dataBean, lang: language };
                try {
                        cocoon.sendPage(formResult, viewData);
                }
                catch(error) {
                        print('something goes wrong: ' + error);
                }
        }

}

testDef.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE form SYSTEM "../formtemplate.dtd">
<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition";
    id="test">
   <fd:widgets>
      <fd:field id="name" required="true">
         <fd:label>Name</fd:label>
         <fd:datatype base="string"/>
      </fd:field>
       <fd:repeater id="workshops">
           <fd:label>Workshops</fd:label>
           <fd:widgets>
               <fd:field id="workshop">
                   <fd:label>Name</fd:label>
                   <fd:datatype base="string"/>
               </fd:field>
               <fd:row-action id="up" command="move-up"/>

               <fd:row-action id="down" command="move-down"/>
           </fd:widgets>
       </fd:repeater>
       <fd:submit id="saveButton" action-command="saveButtonAction">
           <fd:label>Submit</fd:label>
       </fd:submit>
   </fd:widgets>
</fd:form>


testBind.xml

<?xml version="1.0" encoding="UTF-8"?>
<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding"; id="test" path="/">
    <fb:value id="name" path="name"/>
<fb:simple-repeater id="workshops" parent-path="." row-path="workshops">
        <fb:value id="workshop" path="workshop"/>
    </fb:simple-repeater>
</fb:context>


test.jx

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE page SYSTEM "../osn.dtd">
<jx:template xmlns:jx="http://apache.org/cocoon/templates/jx/1.0";
   xmlns:ft="http://apache.org/cocoon/forms/1.0#template";
   xmlns:fi="http://apache.org/cocoon/forms/1.0#instance";>
   <!-- Import the macros that define CForms template elements -->
<jx:import uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>
   <html>
      <head>
         <title>registration</title>
      </head>
      <body>
         <h1>registration</h1>
<ft:form-template action="continue" method="post" ajax="true" id="test">
            <ft:continuation-id/>
            <table class="formtable">
               <tr>
                  <td class="label">
                     <ft:widget-label id="name"/>
                  </td>
                  <td>
                     <ft:widget id="name"/>
                  </td>
               </tr>
               <tr>
                  <td class="label">
                     <ft:widget-label id="workshops"/>
                  </td>
                  <td>
                     <ft:repeater id="workshops">
                        <table style="float: left;">
                           <tbody>
                              <tr>
                                 <th/>
                                 <th>
<ft:repeater-widget-label widget-id="workshop"/>
                                 </th>
                                 <th/>
                              </tr>
                              <ft:repeater-rows>
                                 <tr>
                                    <td> ${repeaterLoop.index + 1} </td>
                                    <td>
                                       <ft:widget id="workshop"/>
                                    </td>
                                    <td>
                                       <jx:choose>
<jx:when test="${repeaterLoop.first}"> <img src="resources/forms/img/blank_btn.gif"/>
                                          </jx:when>
                                          <jx:otherwise>
                                             <ft:widget id="up">
                                                <fi:styling type="image"

src="resources/forms/img/move_up.gif"/>
                                             </ft:widget>
                                          </jx:otherwise>
                                       </jx:choose>
                                       <jx:choose>
<jx:when test="${repeaterLoop.last}"> <img src="resources/forms/img/blank_btn.gif"/>
                                          </jx:when>
                                          <jx:otherwise>
                                             <ft:widget id="down">
                                                <fi:styling type="image"

src="resources/forms/img/move_down.gif"/>
                                             </ft:widget>
                                          </jx:otherwise>
                                       </jx:choose>
                                    </td>
                                 </tr>
                              </ft:repeater-rows>
                           </tbody>
                        </table>
                     </ft:repeater>
                  </td>
               </tr>
               <tr>
                  <td/>
                  <td>
                     <ft:widget id="saveButton"/>
                  </td>
               </tr>
            </table>
         </ft:form-template>
      </body>
   </html>
</jx:template>


testResult.jx

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE page SYSTEM "../../system/osn.dtd">
<jx:template xmlns:jx="http://apache.org/cocoon/templates/jx/1.0";>
   <html>
      <head>
         <title>registration</title>
      </head>
      <body>
         <h1>registration result</h1>
         <p>
            <strong>${beandata.name}</strong>
            <br/> The workshops ordered to my preference: <br/>
<jx:forEach var="item" items="${beandata.workshops}" varStatus="status" step="1">
               <strong>
<jx:if test="${status.count &lt; 10}">&nbsp;</jx:if> ${status.count}:
                  ${item.workshop}</strong>
               <br/>
            </jx:forEach>
         </p>
      </body>
   </html>
</jx:template>


sitemap snippet

         <map:match pattern="**/test.jx">
<map:generate type="jx" src="system/forms/test.jx" label="debug1">
               <map:parameter name="lang" value="{1}"/>
            </map:generate>
            <map:transform type="browser-update"/>
<map:transform src="system/xsl/forms-samples-styling.xsl" label="debug4"/> <map:transform src="system/xsl/stripnamespaces.xsl" label="debug3"/>
            <map:select type="ajax-request">
               <map:when test="true">
                  <map:serialize type="xml"/>
               </map:when>
               <map:otherwise>
                  <map:serialize type="xhtml" encoding="UTF-8"/>
               </map:otherwise>
            </map:select>
         </map:match>
         <map:match pattern="**/testResult.jx">
            <map:generate type="jx" src="system/forms/testResult.jx"
               label="debug1"/>
            <map:transform src="system/xsl/stripnamespaces.xsl"/>
            <map:serialize type="xhtml" encoding="UTF-8"/>
         </map:match>


Reply via email to