cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r170388 - in /cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/generation: JXMacrosHelper.java jx-macros.xml
Date Mon, 16 May 2005 13:50:09 GMT
Author: reinhard
Date: Mon May 16 06:50:08 2005
New Revision: 170388

URL: http://svn.apache.org/viewcvs?rev=170388&view=rev
Log:
make cforms-macros useable in non-Flowscript scenarios

Modified:
    cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java
    cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/generation/jx-macros.xml

Modified: cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java?rev=170388&r1=170387&r2=170388&view=diff
==============================================================================
--- cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java
(original)
+++ cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java
Mon May 16 06:50:08 2005
@@ -45,6 +45,7 @@
 public class JXMacrosHelper {
 
     private XMLConsumer cocoonConsumer;
+    private Request request;
     private ArrayStack stack = new ArrayStack();
     private Map classes; // lazily created
     private boolean ajaxMode;
@@ -62,7 +63,21 @@
 
     public JXMacrosHelper(XMLConsumer consumer, Request request) {
         this.cocoonConsumer = consumer;
+        this.request = request;
         this.ajaxMode = request.getParameter("cocoon-ajax") != null;
+    }
+    
+
+    public Form getForm(Form form, String attributeName) {
+        Form returnForm = form;
+        // if there hasn't been passed a form object, try to find it in the request
+        if(returnForm == null) {
+            returnForm = (Form) this.request.getAttribute(attributeName);
+        }
+        if(returnForm != null) {
+            return returnForm;
+        }
+        throw new NullPointerException("There hasn't been passed a form object to the template!");
     }
 
     public void startForm(Form form, Map attributes) throws SAXException {

Modified: cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/generation/jx-macros.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/generation/jx-macros.xml?rev=170388&r1=170387&r2=170388&view=diff
==============================================================================
--- cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/generation/jx-macros.xml (original)
+++ cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/generation/jx-macros.xml Mon
May 16 06:50:08 2005
@@ -1,3 +1,19 @@
+<!--
+  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.
+-->
+
 <!-- An implementation of the CForms template engine as a JXTemplate tag library -->
     
 <jx:template xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
@@ -8,7 +24,7 @@
     -->
     <jx:macro name="form-template" targetNamespace="http://apache.org/cocoon/forms/1.0#template">
       <jx:set var="cformsHelper" value="#{org.apache.cocoon.forms.generation.JXMacrosHelper.createHelper($cocoon/consumer,$cocoon/request)}"/>
-      <jx:set var="form" value="${CocoonFormsInstance}"/>
+      <jx:set var="form" value="${cformsHelper.getForm(CocoonFormsInstance, cocoon.parameters['attribute-name'])}"/>
       <jx:if test="${cformsHelper.isVisible(form)}">
         <jx:set var="cformsDummy" value="${cformsHelper.startForm(form, macro.arguments)}"/>
         <!-- the form is also the current widget -->



Mime
View raw message