Here's the complete Flowscript code which drives the bean editor application:
0002 * Licensed to the Apache Software Foundation (ASF) under one or more
0003 * contributor license agreements. See the NOTICE file distributed with
0004 * this work for additional information regarding copyright ownership.
0005 * The ASF licenses this file to You under the Apache License, Version 2.0
0006 * (the "License"); you may not use this file except in compliance with
0007 * the License. You may obtain a copy of the License at
0008 *
0009 * http://www.apache.org/licenses/LICENSE-2.0
0010 *
0011 * Unless required by applicable law or agreed to in writing, software
0012 * distributed under the License is distributed on an "AS IS" BASIS,
0013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014 * See the License for the specific language governing permissions and
0015 * limitations under the License.
0016 */
0018 // flowscript for supersonic tour example app
0020 // Load the javascript Cocoon Forms library
0021 cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
0023 // Access java "database" facade object
0024 var db = Packages.org.apache.cocoon.samples.tour.beans.DatabaseFacade.getInstance();
0026 // Query all TaskBean objects and display them
0027 function query_allTasks() {
0028 var list = db.getTasks();
0030 cocoon.sendPage("internal/generate-view/taskList", {
0031 title : "List of tasks",
0032 task : list,
0033 db : db
0034 });
0035 }
0037 // Query a single TaskBean object and display it
0038 function query_singleTask() {
0039 var id = cocoon.request.getParameter("taskId");
0040 var bean = db.getTaskBeanById(id);
0041 displayTaskBean(id,bean);
0042 }
0044 // Edit a single TaskBean object using Cocoon Forms
0045 function singleTaskEditor(form) {
0046 var id = cocoon.request.getParameter("taskId");
0047 var bean = db.getTaskBeanById(id);
0049 form.load(bean);
0050 form.showForm("internal/show-form/singleTask");
0051 form.save(bean);
0052 displayTaskBean(id,bean);
0053 }
0055 // Display a single TaskBean
0056 function displayTaskBean(id,bean) {
0057 cocoon.sendPage("internal/generate-view/singleTask", {
0058 title : "Task #" + id,
0059 task : bean,
0060 selectedTaskId : id
0061 });
0062 }