Author: jeremy Date: Mon Oct 11 06:37:26 2004 New Revision: 54583 Added: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/query/screens/cancelled.xml Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/query/query.js cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/query/screens/messages.xml Log: making cancel form work
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/query/query.js ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/query/query.js (original) +++ cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/query/query.js Mon Oct 11 06:37:26 2004 @@ -63,13 +63,19 @@ query = new SimpleLuceneQueryBean(type, null, match, field, cocoon.parameters["query"]); } else if ( "".equals(historyid) ) { // test for: new query query = new SimpleLuceneQueryBean(type, null, match, field, ""); - edit(query); + if (!edit(query)) { + cocoon.sendPage("screen/cancelled", {message: "cancel.note"}); + return; + } } else { try { var edition = history.get(historyid); if (page == null) { // edit a query already in the history query = edition.copy(); // clone it first so history items are separate - edit(query); + if (!edit(query)) { + cocoon.sendPage("screen/cancelled", {message: "cancel.note"}); + return; + } } else { // page a query already in the history query = edition; query.page = page; @@ -123,6 +129,9 @@ form.showForm(cocoon.parameters["form"]); if ("submit".equals(form.submitId)) { form.save(query); + return true; + } else { + return false; } } Added: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/query/screens/cancelled.xml ============================================================================== --- (empty file) +++ cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/query/screens/cancelled.xml Mon Oct 11 06:37:26 2004 @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + 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. +--> +<page xmlns:t="http://apache.org/cocoon/templates/jx/1.0" + xmlns:i18n="http://apache.org/cocoon/i18n/2.1"> + <title>Cancelled</title> + <content> + <p><i18n:text i18n:catalogue="local">#{message}</i18n:text></p> + </content> +</page> Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/query/screens/messages.xml ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/query/screens/messages.xml (original) +++ cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/query/screens/messages.xml Mon Oct 11 06:37:26 2004 @@ -144,6 +144,7 @@ <message key="simple.page.note">Enter some words and hit submit.</message> <message key="simple.page.title">A simple query</message> <message key="required.note">* required</message> + <message key="cancel.note">you cancelled your edit</message> <!-- errors --> <message key="search.error.noquery">there was no query</message> <message key="search.error.nohistory">you have no history at the moment</message>