cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r170749 - in /cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/generation: JXMacrosHelper.java jx-macros.xml
Date Wed, 18 May 2005 13:34:42 GMT
Author: reinhard
Date: Wed May 18 06:34:41 2005
New Revision: 170749

URL: http://svn.apache.org/viewcvs?rev=170749&view=rev
Log:
make use of jxt possible in non flowscript scenarios - sync with trunk; unfortunatly it doesn't
work, maybe because of a problem with the old JXTemplateGenerator. I don't have time to investigate
further on this

Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/generation/jx-macros.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java?rev=170749&r1=170748&r2=170749&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java
Wed May 18 06:34:41 2005
@@ -21,6 +21,7 @@
 import java.util.Locale;
 import java.util.Map;
 
+import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.forms.Constants;
 import org.apache.cocoon.forms.formmodel.Form;
 import org.apache.cocoon.forms.formmodel.Repeater;
@@ -42,6 +43,7 @@
 public class JXMacrosHelper {
 
     private XMLConsumer cocoonConsumer;
+    private Request request;    
     private ArrayStack stack = new ArrayStack();
     private Map classes; // lazily created
 
@@ -51,14 +53,28 @@
      * @param consumer the generator's consumer
      * @return a helper object
      */
-    public static JXMacrosHelper createHelper(XMLConsumer consumer) {
-        return new JXMacrosHelper(consumer);
+    public static JXMacrosHelper createHelper(XMLConsumer consumer, Request request) {
+        System.out.println("bla");
+        return new JXMacrosHelper(consumer, request);
     }
 
-    public JXMacrosHelper(XMLConsumer consumer) {
+    public JXMacrosHelper(XMLConsumer consumer, Request request) {
         this.cocoonConsumer = consumer;
+        this.request = request;
     }
+    
 
+    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 {
         // build attributes
         AttributesImpl attrs = new AttributesImpl();

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/generation/jx-macros.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/generation/jx-macros.xml?rev=170749&r1=170748&r2=170749&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/generation/jx-macros.xml
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/generation/jx-macros.xml
Wed May 18 06:34:41 2005
@@ -23,8 +23,8 @@
         ft:form-template
     -->
     <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)}"/>
-      <jx:set var="form" value="${CocoonFormsInstance}"/>
+      <jx:set var="cformsHelper" value="#{org.apache.cocoon.forms.generation.JXMacrosHelper.createHelper($cocoon/consumer,$cocoon/request)}"/>
+      <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