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) {