You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2009/02/03 16:32:19 UTC

svn commit: r740321 [3/3] - in /lenya/sandbox/atom: ./ modules/ modules/atom/ modules/atom/config/ modules/atom/config/cocoon-xconf/ modules/atom/java/ modules/atom/java/src/ modules/atom/java/src/org/ modules/atom/java/src/org/apache/ modules/atom/jav...

Added: lenya/sandbox/atom/modules/rest/rest.js
URL: http://svn.apache.org/viewvc/lenya/sandbox/atom/modules/rest/rest.js?rev=740321&view=auto
==============================================================================
--- lenya/sandbox/atom/modules/rest/rest.js (added)
+++ lenya/sandbox/atom/modules/rest/rest.js Tue Feb  3 15:32:16 2009
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.
+ *
+ */
+ 
+function handleRequest() {
+
+    var handler;
+    try {
+        var role = cocoon.parameters["handler"];
+        var lastDot = role.lastIndexOf(".");
+        var className = role.substring(lastDot + 1);
+        var firstChar = className.substring(0, 1).toUpperCase();
+        role = role.substring(0, lastDot + 1) + firstChar + className.substring(1);
+        
+        var method = cocoon.request.getMethod().toLowerCase();
+        handler = cocoon.getComponent(role);
+        var view = eval("handler['" + method + "']()");
+        cocoon.sendPage("view/" + view.getUri(), { "view" : view });
+    } finally {
+        if (handler) {
+            cocoon.releaseComponent(handler);
+        }
+    }
+}
+ 
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org