dev@javaserverfaces.java.net

[REVIEW] Issue #70 - HtmlTaglib Generates Release Methods

From: Jacob Hookom <jacob_at_hookom.net>
Date: Fri, 12 Nov 2004 08:45:40 -0600

https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=70

AW> .... you're correct with regards to JSP 2.0, where release() is *finally*
AW> specified as called once before it is truly gone. However, JSP 1.2 was
AW> (sadly) not quite so specific, and release() can be called repeatedly.
AW> There's a diagram that's in both 1.2 and 2.0 where the 1.2 version has
AW> an extra arrow leading away from the "release()" state.
AW> So, in JSF 1.2, therefore, we can rely on the JSP 2.0 behavior, while
AW> any JSF 1.1 release theoretically has to suffer all the behavior
AW> allowed by JSP 1.2.

This changebundle generates the release() method on all tags. Tests for JSF-RI
were run successfully--

SECTION: Changes

M HtmlTaglibGenerator.java
-added 'tagHandlerReleaseMethod()' which follows the same logic as the ivar
generation to set properties to null or if primitive, their default values.

SECTION: Diffs

Index: HtmlTaglibGenerator.java
===================================================================
RCS file:
/shared/data/ccvs/repository/javaserverfaces-sources/jsf-tools/src/com/sun/faces/generate/HtmlTaglibGenerator.java,v
retrieving revision 1.29
diff -u -r1.29 HtmlTaglibGenerator.java
--- HtmlTaglibGenerator.java 29 Oct 2004 00:56:39 -0000 1.29
+++ HtmlTaglibGenerator.java 12 Nov 2004 14:32:12 -0000
@@ -35,7 +35,7 @@
  * package.
  */
 public class HtmlTaglibGenerator extends AbstractGenerator {
-
+
     // -------------------------------------------------------- Static Variables
     
     // Log instance for this class
@@ -545,6 +545,86 @@
         // Generate Log declaration
         writer.write(" public static Log log =
LogFactory.getLog("+tagClassName+".class);\n\n");
     }
+
+ private static void tagHandlerReleaseMethod() throws Exception {
+ writer.write(" //\n // Release Method\n //\n\n");
+
+ writer.write(" public void release() {\n");
+ writer.write(" super.release();\n\n");
+ writer.write(" // component properties\n");
+
+ // Generate from component properties
+ //
+ PropertyBean[] properties = component.getProperties();
+ PropertyBean property = null;
+ String propertyName = null;
+ String propertyType = null;
+ String ivar = null;
+ for (int i = 0, len = properties.length; i < len; i++) {
+ if (null == (property = properties[i])) {
+ continue;
+ }
+ if (!property.isTagAttribute()) {
+ continue;
+ }
+ propertyName = property.getPropertyName();
+ propertyType = property.getPropertyClass();
+
+ // SPECIAL - Don't generate these properties
+ if (propertyName.equals("binding") || propertyName.equals("id")
+ || propertyName.equals("rendered")) {
+ continue;
+ }
+
+ ivar = mangle(propertyName);
+ writer.write(" this." + ivar + " = ");
+ if (primitive(propertyType) &&
!(valueBindingEnabledProperties.contains(propertyName)
+ || methodBindingEnabledProperties.contains(propertyName))) {
+ writer.write((String) defaults.get(propertyType));
+ } else {
+ writer.write("null");
+ }
+ writer.write(";\n");
+ /*
+ if (valueBindingEnabledProperties.contains(propertyName)
+ || methodBindingEnabledProperties.contains(propertyName)) {
+ writer.write(" private java.lang.String " + ivar + ";\n");
+ } else {
+ writer
+ .write(" private " + propertyType + " " + ivar
+ + ";\n");
+ if (primitive(propertyType)) {
+ writer.write(" = " + (String) defaults.get(propertyType)
+ + ";\n");
+ }
+ }
+ */
+ }
+
+ writer.write("\n");
+ writer.write(" // rendered attributes\n");
+
+ // Generate from renderer attributes..
+ //
+ AttributeBean[] attributes = renderer.getAttributes();
+ AttributeBean attribute = null;
+ String attributeName = null;
+ String attributeType = null;
+ for (int i = 0, len = attributes.length; i < len; i++) {
+ if (null == (attribute = attributes[i])) {
+ continue;
+ }
+ if (!attribute.isTagAttribute()) {
+ continue;
+ }
+ attributeName = attribute.getAttributeName();
+ attributeType = attribute.getAttributeClass();
+
+ ivar = mangle(attributeName);
+ writer.write(" this." + ivar + " = null;\n");
+ }
+ writer.write(" }\n\n");
+ }
 
     /**
      * Generate Tag Handler instance variables from component properties
@@ -1133,6 +1213,7 @@
                 } else {
                     tagHandlerSupportMethods();
                 }
+ tagHandlerReleaseMethod();
                 tagHandlerSuffix();
             
                 // Flush and close the Writer



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net