cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simo...@apache.org
Subject svn commit: r449454 - in /cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF: ./ pagination/
Date Sun, 24 Sep 2006 18:32:28 GMT
Author: simoneg
Date: Sun Sep 24 11:32:28 2006
New Revision: 449454

URL: http://svn.apache.org/viewvc?view=rev&rev=449454
Log:
Enhanced repeater example

Added:
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/flow.js
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/paginated.bnd.xml
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/paginated.def.xml
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/paginated.tpl.xml
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/sitemap.xmap
Modified:
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/welcome.xml

Added: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/flow.js
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/flow.js?view=auto&rev=449454
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/flow.js
(added)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/flow.js
Sun Sep 24 11:32:28 2006
@@ -0,0 +1,45 @@
+cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
+
+function do_paginated() {
+    var form = new Form("paginated.def.xml");
+    form.createBinding("paginated.bnd.xml");
+    
+    var countries = new Array();
+    countries[0] = "Austria";
+    countries[1] = "Italy";
+    countries[2] = "Usa";
+    countries[3] = "France";
+    countries[4] = "Germany";
+    countries[5] = "India";
+    countries[6] = "UK";
+    countries[7] = "Sweden";
+    
+    var team = new Packages.org.apache.cocoon.forms.samples.dreamteam.Team()
+    var i;
+    for (i = 1; i < 101 ; i++) {
+      var player = new Packages.org.apache.cocoon.forms.samples.dreamteam.TeamMember();
+      player.setMemberId(i);
+      player.setName("Name "+i);
+      player.setCountry(countries[i % countries.length]);
+      player.setPosition("Position "+1);
+      team.addMember(player);
+    }
+    form.setAttribute("counter",i-1);
+    
+    form.load(team);
+    form.showForm("paginated-display-pipeline");
+    form.save(team);
+    
+    cocoon.sendPage("paginated-result-pipeline",{"team":team});
+}
+
+
+function doMap() {
+    var form = new Form("forms/map-definition.xml");
+    form.showForm("map-display-pipeline.jx");
+    var model = form.getModel();
+    var mapValue1 = form.getWidget().lookupWidget("map1").getValue().toString();
+    var mapValue2 = form.getWidget().lookupWidget("map2").getValue().toString();
+    var mapValue3 = form.getWidget().lookupWidget("map3").getValue().toString();
+    cocoon.sendPage("map-result-pipeline.jx",{"mapValue1":mapValue1,"mapValue2":mapValue2,"mapValue3":mapValue3});
+}
\ No newline at end of file

Added: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/paginated.bnd.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/paginated.bnd.xml?view=auto&rev=449454
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/paginated.bnd.xml
(added)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/paginated.bnd.xml
Sun Sep 24 11:32:28 2006
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<fb:context path="/"
+  xmlns:fb="http://apache.org/cocoon/forms/1.0#binding">
+
+  <fb:repeater id="players" parent-path="." row-path="team">
+
+    <fb:identity>
+      <fb:value id="id" path="memberId" />
+    </fb:identity>
+
+    <fb:on-bind>
+      <fb:value id="id" path="memberId" />
+      <fb:value id="name" path="name" />
+      <fb:value id="country" path="country" />
+      <fb:value id="position" path="position" />
+    </fb:on-bind>
+
+    <fb:on-insert-row>
+      <fb:insert-bean classname="org.apache.cocoon.forms.samples.dreamteam.TeamMember"
+        addmethod="addMember" />
+    </fb:on-insert-row>
+
+  </fb:repeater>
+
+</fb:context>
\ No newline at end of file

Added: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/paginated.def.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/paginated.def.xml?view=auto&rev=449454
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/paginated.def.xml
(added)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/paginated.def.xml
Sun Sep 24 11:32:28 2006
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<fd:form id="form"
+  xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
+
+  <fd:widgets>
+    <fd:repeater id="players">
+      <fd:pages initial="1" size="20" page-field="topage" />
+
+      <fd:widgets>
+        <fd:booleanfield id="select" validate="false" />
+        <fd:field id="id" state="output">
+          <fd:label>ID</fd:label>
+          <fd:datatype base="string" />
+        </fd:field>
+        <fd:field id="name" required="true">
+          <fd:label>Name</fd:label>
+          <fd:datatype base="string" />
+        </fd:field>
+        <fd:field id="country" required="true">
+          <fd:label>Country</fd:label>
+          <fd:datatype base="string" />
+        </fd:field>
+        <fd:field id="position" required="true">
+          <fd:label>Position</fd:label>
+          <fd:datatype base="string" />
+        </fd:field>
+      </fd:widgets>
+    </fd:repeater>
+
+    <fd:repeater-action id="page-first" command="page-first"
+      repeater="players">
+      <fd:label>&lt;&lt;</fd:label>
+    </fd:repeater-action>
+    <fd:repeater-action id="page-prev" command="page-prev"
+      repeater="players">
+
+      <fd:label>&lt;</fd:label>
+    </fd:repeater-action>
+    <fd:repeater-action id="page-next" command="page-next"
+      repeater="players">
+      <fd:label>&gt;</fd:label>
+    </fd:repeater-action>
+    <fd:repeater-action id="page-last" command="page-last"
+      repeater="players">
+      <fd:label>&gt;&gt;</fd:label>
+    </fd:repeater-action>
+    <fd:field id="topage">
+      <fd:label>topage</fd:label>
+      <fd:datatype base="integer" />
+    </fd:field>
+    <fd:repeater-action id="page-custom" command="page-custom"
+      repeater="players">
+      <fd:label>go</fd:label>
+    </fd:repeater-action>
+    <fd:repeater-action id="remove" command="delete-rows"
+      repeater="players" select="select">
+      <fd:label>Remove selected players</fd:label>
+    </fd:repeater-action>
+
+    <fd:repeater-action id="sort-natural" command="sort-by"
+      repeater="players">
+      <fd:label>Natural</fd:label>
+    </fd:repeater-action>
+    <fd:repeater-action id="sort-by-name" command="sort-by"
+      repeater="players" field="name">
+      <fd:label>Sort by name</fd:label>
+    </fd:repeater-action>
+    <fd:repeater-action id="sort-by-surname" command="sort-by"
+      repeater="players" field="country">
+      <fd:label>Sort by country</fd:label>
+    </fd:repeater-action>
+
+    <fd:filterfield id="filter-name" repeater="players" field="name">
+      <fd:label>by name</fd:label>
+      <fd:datatype base="string" />
+    </fd:filterfield>
+    <fd:filterfield id="filter-country" repeater="players"
+      field="country">
+      <fd:label>by country</fd:label>
+      <fd:datatype base="string" />
+    </fd:filterfield>
+    <fd:filterfield id="filter-position" repeater="players"
+      field="position">
+      <fd:label>by position</fd:label>
+      <fd:datatype base="string" />
+    </fd:filterfield>
+    <fd:action id="filter-button">
+      <fd:label>Apply</fd:label>
+    </fd:action>
+
+    <fd:repeater-action id="add" command="add-row" repeater="players">
+      <fd:label>Add player</fd:label>
+      <fd:on-action>
+        <fd:javascript>
+          var form = event.source.form; var count = new
+          java.lang.Integer(form.getAttribute("counter").intValue() +
+          1); form.setAttribute("counter", count); var repeater =
+          form.getChild("players"); repeater.getRow(repeater.getSize() -
+          1).getChild("id").setValue(count+"");
+        </fd:javascript>
+      </fd:on-action>
+    </fd:repeater-action>
+
+
+    <fd:submit id="submit">
+      <fd:label>submit</fd:label>
+    </fd:submit>
+
+  </fd:widgets>
+</fd:form>
\ No newline at end of file

Added: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/paginated.tpl.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/paginated.tpl.xml?view=auto&rev=449454
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/paginated.tpl.xml
(added)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/paginated.tpl.xml
Sun Sep 24 11:32:28 2006
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
+  xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
+  xmlns:ft="http://apache.org/cocoon/forms/1.0#template">
+
+  <jx:import
+    uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml" />
+
+  <title>Sample enhanced repeater</title>
+  <content>
+
+    <ft:form-template action="#{$cocoon/continuation/id}.continue"
+      method="POST" ajax="false">
+
+      <ft:repeater id="players">
+
+        <p>
+          <b>
+            page
+            ${repeater.getDisplayableCurrentPage()}/${repeater.getDisplayableLastPage()}
+          </b>
+        </p>
+
+        <p>
+          <i>navigate</i>
+          <jx:if test="${!repeater.isFirstPage()}">
+            <ft:widget id="../page-first" />
+            <ft:widget id="../page-prev" />
+          </jx:if>
+          <jx:if test="${!repeater.isLastPage()}">
+            <ft:widget id="../page-next" />
+            <ft:widget id="../page-last" />
+          </jx:if>
+          <br />
+
+          <i>Jump to page</i>
+          <ft:widget id="../topage" />
+          <ft:widget id="../page-custom" />
+          <br />
+
+          <i>Sort</i>
+          <ft:widget id="../sort-natural" />
+          <ft:widget id="../sort-by-name" />
+          <ft:widget id="../sort-by-surname" />
+          <br />
+        </p>
+
+        <table>
+          <tbody>
+            <tr>
+              <th />
+
+              <th>
+                <ft:repeater-widget-label widget-id="id" />
+              </th>
+              <th>
+                <ft:repeater-widget-label widget-id="name" />
+              </th>
+              <th>
+                <ft:repeater-widget-label widget-id="country" />
+              </th>
+              <th>
+                <ft:repeater-widget-label widget-id="position" />
+              </th>
+            </tr>
+            <tr>
+              <th colspan="2">
+                <ft:widget id="../filter-button"/>
+              </th>
+              <th>
+                <ft:widget id="../filter-name" />
+              </th>
+              <th>
+                <ft:widget id="../filter-country" />
+              </th>
+              <th>
+                <ft:widget id="../filter-position" />
+              </th>
+            </tr>
+            <ft:repeater-rows>
+              <tr class="forms-row-${repeaterLoop.index % 2}">
+                <td>
+                  <ft:widget id="select" />
+                </td>
+                <td>
+                  <ft:widget id="id" />
+                </td>
+
+                <td>
+                  <ft:widget id="name" />
+                </td>
+                <td>
+                  <ft:widget id="country" />
+                </td>
+                <td>
+                  <ft:widget id="position" />
+                </td>
+              </tr>
+            </ft:repeater-rows>
+          </tbody>
+        </table>
+      </ft:repeater>
+      <p>
+        <ft:widget id="add" />
+        <ft:widget id="remove" />
+      </p>
+
+      <p>
+        <ft:widget id="submit" />
+      </p>
+    </ft:form-template>
+
+  </content>
+</page>
\ No newline at end of file

Added: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/sitemap.xmap?view=auto&rev=449454
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/sitemap.xmap
(added)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/pagination/sitemap.xmap
Sun Sep 24 11:32:28 2006
@@ -0,0 +1,93 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+  <map:components>
+  </map:components>
+
+  <map:views>
+    <map:view name="content" from-label="content">
+      <map:serialize type="xml"/>
+    </map:view>
+  </map:views>
+ 
+  <map:resources>
+    <!-- this will later become a virtual transformer -->
+    <map:resource name="simple-page2html">
+      <map:transform src="context://samples/common/style/xsl/html/simple-page2html.xsl">
+        <map:parameter name="contextPath" value="{request:contextPath}"/>
+        <map:parameter name="servletPath" value="{request:servletPath}"/>
+        <map:parameter name="sitemapURI" value="{request:sitemapURI}"/>
+        <map:parameter name="file" value="{file}"/>
+        <map:parameter name="remove" value="{../0}"/>
+      </map:transform> 
+    </map:resource>
+  </map:resources>
+
+  <!-- indicates what flowscript to attach to this sitemap -->
+  <map:flow language="javascript">
+    <map:script src="flow.js"/>
+  </map:flow>
+
+  <map:pipelines>
+
+    <map:pipeline type="noncaching">
+
+      <map:match pattern="*.continue">
+        <map:call continuation="{1}"/>
+      </map:match>
+
+      <map:match pattern="*-display-pipeline">
+        <!-- pipeline to show the form -->
+        <map:generate src="{1}.tpl.xml" type="jx"/>
+         <map:transform type="browser-update"/>
+        <map:transform type="i18n">
+          <map:parameter name="locale" value="en-US"/>
+        </map:transform>
+        <map:call resource="simple-page2html">
+          <map:parameter name="file" value="{1}.tpl.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>
+ 
+      <map:match pattern="*-result-pipeline.jx">
+        <map:generate type="jx" src="{1}-result.xml"/>
+        <map:call resource="simple-page2html">
+          <map:parameter name="file" value="{1}-success.xml"/>
+        </map:call>
+        <map:serialize/>
+      </map:match>
+      
+      <map:match pattern="*.do">
+        <map:call function="do_{1}"/>
+      </map:match>
+
+    </map:pipeline>
+  </map:pipelines>
+
+</map:sitemap>

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/welcome.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/welcome.xml?view=diff&rev=449454&r1=449453&r2=449454
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/welcome.xml
(original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/welcome.xml
Sun Sep 24 11:32:28 2006
@@ -171,4 +171,11 @@
     <sample name="Hotel Booking Sample" href="library/hotel.flow">Hotel Booking Sample,
elaborate use of libraries.</sample>
   </group>
 
+  <group name="Repeater advanced features">
+    <note>
+      This demonstrates the Google Summer of Code 2006 improvements to the repeater.
+    </note>
+    <sample name="Pagination, sorting and filtering" href="pagination/paginated.do">Pagination,
sorting and filtering.</sample>
+  </group>
+
 </samples>



Mime
View raw message