You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by th...@apache.org on 2005/09/02 13:51:44 UTC
svn commit: r267188 - in /lenya/trunk/src/webapp/lenya/usecases:
usecases-util.js usecases.js
Author: thorsten
Date: Fri Sep 2 04:51:39 2005
New Revision: 267188
URL: http://svn.apache.org/viewcvs?rev=267188&view=rev
Log:
Formating changes of usecase.js. Added basic flow util js which contains io functions that can be used in the custom flow extensions. Activated the util class in the usecase.js.
Added:
lenya/trunk/src/webapp/lenya/usecases/usecases-util.js (with props)
Modified:
lenya/trunk/src/webapp/lenya/usecases/usecases.js
Added: lenya/trunk/src/webapp/lenya/usecases/usecases-util.js
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/usecases-util.js?rev=267188&view=auto
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/usecases-util.js (added)
+++ lenya/trunk/src/webapp/lenya/usecases/usecases-util.js Fri Sep 2 04:51:39 2005
@@ -0,0 +1,75 @@
+/*
+ * Copyright 1999-2005 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.
+ *
+ */
+/* $Id: usecases.js 265544 2005-08-31 18:40:31Z thorsten $ */
+
+function loadDocument(uri) {
+ var parser = null;
+ var source = null;
+ var resolver = null;
+ try {
+ parser = cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
+ resolver = cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+ source = resolver.resolveURI(uri);
+ var is = new Packages.org.xml.sax.InputSource(source.getInputStream());
+ is.setSystemId(source.getURI());
+ return parser.parseDocument(is);
+ } finally {
+ if (source != null)
+ resolver.release(source);
+ cocoon.releaseComponent(parser);
+ cocoon.releaseComponent(resolver);
+ }
+}
+function saveDocument(document, uri) {
+ var source = null;
+ var resolver = null;
+ var outputStream = null;
+ try {
+ resolver = cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+ source = resolver.resolveURI(uri);
+
+ var tf = Packages.javax.xml.transform.TransformerFactory.newInstance();
+
+ if (source instanceof Packages.org.apache.excalibur.source.ModifiableSource
+ && tf.getFeature(Packages.javax.xml.transform.sax.SAXTransformerFactory.FEATURE)) {
+
+ outputStream = source.getOutputStream();
+ var transformerHandler = tf.newTransformerHandler();
+ var transformer = transformerHandler.getTransformer();
+ transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.INDENT, "true");
+ transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.METHOD, "xml");
+ transformerHandler.setResult(new Packages.javax.xml.transform.stream.StreamResult(outputStream));
+
+ var streamer = new Packages.org.apache.cocoon.xml.dom.DOMStreamer(transformerHandler);
+ streamer.stream(document);
+ } else {
+ throw new Packages.org.apache.cocoon.ProcessingException("Cannot write to source " + uri);
+ }
+ } finally {
+ if (source != null)
+ resolver.release(source);
+ cocoon.releaseComponent(resolver);
+ if (outputStream != null) {
+ try {
+ outputStream.flush();
+ outputStream.close();
+ } catch (error) {
+ cocoon.log.error("Could not flush/close outputstream: " + error);
+ }
+ }
+ }
+}
\ No newline at end of file
Propchange: lenya/trunk/src/webapp/lenya/usecases/usecases-util.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: lenya/trunk/src/webapp/lenya/usecases/usecases.js
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/usecases.js?rev=267188&r1=267187&r2=267188&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/usecases.js (original)
+++ lenya/trunk/src/webapp/lenya/usecases/usecases.js Fri Sep 2 04:51:39 2005
@@ -17,7 +17,7 @@
/* $Id$ */
cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
-// cocoon.load("usecases-util.js");
+ cocoon.load("usecases-util.js");
/* Helper method to add all request parameters to a usecase */
function passRequestParameters(flowHelper, usecase) {
@@ -116,16 +116,18 @@
var templateUri = view.getTemplateURI();
if (templateUri) {
/*
- var generic - Generic object that can be used in all custom flow code
- that is added by usecases. Right now it focus on document opertations
- but the properties should be extended through user/dev feedback.
- The intention of this var is to provide a generic global flow object
- (like in lots of cocoon examples) that can be accessed through out the different flow stages.
- Alternatively one can use the invoking java class by providing bean properties methods
- (getter/setter methods) in this class and use them within the extensions (see usecase doc).
- FIXME: Add cforms integration howto to the documentation.
- */
+ * var generic - Generic object that can be used in all custom flow code
+ * that is added by usecases. Right now it focus on document opertations
+ * but the properties should be extended through user/dev feedback.
+ * The intention of this var is to provide a generic global flow object
+ * (like in lots of cocoon examples) that can be accessed through out the different flow stages.
+ * Alternatively one can use the invoking java class by providing bean properties methods
+ * (getter/setter methods) in this class and use them within the extensions (see usecase doc).
+ *
+ * FIXME: Add cforms integration howto to the documentation.
+ */
var generic={doc:null,uri:null,generic:null};
+
var viewUri = "view/" + menu + "/" + view.getTemplateURI();
if (cocoon.log.isDebugEnabled())
cocoon.log.debug("usecases.js::executeUsecase() in usecase " + usecaseName + ", creating view, calling Cocoon with viewUri = [" + viewUri + "]");
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org