No need to propose anything new. Turbine provides this functionality
already indirectly in RunData.getTemplateInfo() methods:
    setTemp(key, value), getTemp(key), getTemp(key, defaultValue), 
    getString(key), and getStringArray(key)

Place your per-request temporary data in:
    data.getTemplateInfo().setTemp("abc", "def")

All TemplateInfo needs for completeness is a removeTemp(key) as 
provided in the patch below. Also I provided a getTempNames() for 
debugging purposes.


I hope that a CVS master can takeover the diff -u from below.
Please let me know if I should send my patched file as an attachment 
to you.


:) Christoph

> >
> > PP should remain being a package for string parameters.
> >
> > If the data.getUser().getTemp() or the context are not suitable
> > for your needs, please send a proposal/patch - e.g. data.getTemp()
> > for something more applicable.
> 
> +1 on this proposal.  Especially since it would eliminate the need for
> this:
> 
> >In fact, I turned around using the session.put(). I reset the values 
> >between each HTTP request using my SessionValidator.
> 
> And it stays within the scope of the RunData object which is supposed to
> store information between modules on a single request.

I first was about to patch RunData, but it seems to me heavy enough
so I accept the indirection to the TemplateInfo.tempStorage instead
of loading RunData with more functions ;-)

> 
> John McNally

------------------------- cut here ------------------------
--- 
Apache-Turbine-20001109/src/java/org/apache/turbine/util/template/TemplateInfo.java    
Fri Sep 29 01:48:02 2000
+++ Apache-Turbine/src/java/org/apache/turbine/util/template/TemplateInfo.java        
+Fri Nov 10 17:13:27 2000
@@ -91,7 +91,7 @@
     public TemplateInfo(RunData data)
     {
         this.data=data;
-        tempStorage = new Hashtable();
+        tempStorage = new Hashtable(10);
     }
 
     /**
@@ -291,5 +291,27 @@
             value = (String)object;
         }
         return value;
+    }
+
+    /**
+     * Remove an object from the  temporary storage.
+     *
+     * @param name A String with the name of the object.
+     * @return The object that was removed or <code>null</code>
+     *         if the name was not a key.
+     */
+    public Object removeTemp(String name)
+    {
+        return tempStorage.remove(name);
+    }
+
+    /*
+     * Returns all the available names in the temporary storage.
+     * 
+     * @return A object array with the keys.
+     */
+    public Object[] getTempKeys()
+    {
+        return tempStorage.keySet().toArray();
     }
 }
------------------------- cut here ------------------------


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to