You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2004/11/11 10:58:59 UTC

svn commit: rev 57425 - cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel

Author: sylvain
Date: Thu Nov 11 01:58:58 2004
New Revision: 57425

Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java
Log:
speedup getRequestParameterName by caching its result

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java	Thu Nov 11 01:58:58 2004
@@ -63,7 +63,12 @@
      * Storage for the widget allocated attributes
      */
     private Map attributes;
- 
+    
+    /**
+     * Lazily computed request parameter name
+     */
+    private String requestParamName;   
+    
     protected AbstractWidget(AbstractWidgetDefinition definition) {
         this.state = definition.getState();
     }
@@ -161,15 +166,22 @@
     }
 
     public String getRequestParameterName() {
-        Widget myParent = getParent();
-        if (myParent != null) {
-            String parentFullId = myParent.getRequestParameterName();
-            // the top level form returns an id == ""
-            if (parentFullId.length() > 0) {
-                return parentFullId + "." + getId();
+        if (this.requestParamName == null) {
+
+            // Default if no parent or parent with empty id
+            this.requestParamName = getId();
+
+            Widget myParent = getParent();
+            if (myParent != null) {
+                String parentFullId = myParent.getRequestParameterName();
+                // the top level form returns an id == ""
+                if (parentFullId.length() > 0) {
+                    this.requestParamName = parentFullId + "." + getId();
+                }
             }
         }
-        return getId();
+        
+        return this.requestParamName;
     }
 
     public Widget lookupWidget(String path) {