cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r406635 - /cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Union.java
Date Mon, 15 May 2006 14:27:32 GMT
Author: bruno
Date: Mon May 15 07:27:31 2006
New Revision: 406635

URL: http://svn.apache.org/viewcvs?rev=406635&view=rev
Log:
Union widget: set the submit widget prematurely (as was also needed for the
action and upload widgets), since otherwise widget values are lost when
switching between union cases.

Modified:
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Union.java

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Union.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Union.java?rev=406635&r1=406634&r2=406635&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Union.java
(original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Union.java
Mon May 15 07:27:31 2006
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,7 +32,7 @@
  */
 public class Union extends AbstractContainerWidget {
 
-    //Note: union instances behave like simple "field" instance with respect to 
+    //Note: union instances behave like simple "field" instance with respect to
     //      XSLT post-processing, the choice of element-name reflects this.
     private static final String UNION_EL = "field";
 
@@ -96,6 +96,13 @@
         // Read current case from request
         String newValue = (String)getValue();
         if (newValue != null && !newValue.equals("")) {
+            // We need to know if the case widget is the submit widget,
+            // and since the submit widget is only determined after the readFromRequest,
+            // we need to do it here prematurely (as happens in Action & Upload)
+            String fullId = caseWidget.getRequestParameterName();
+            if (fullId.equals(formContext.getRequest().getParameter(Form.SUBMIT_ID_PARAMETER)))
{
+               getForm().setSubmitWidget(this.caseWidget);
+            }
 
             if (getForm().getSubmitWidget() == this.caseWidget && !newValue.equals(this.caseValue))
{
                 // If submitted by the case widget and its value has changed, read the values
@@ -111,7 +118,7 @@
                 widget.readFromRequest(formContext);
             }
         }
-        
+
         if (!ObjectUtils.equals(this.caseValue, newValue)) {
             this.caseValue = newValue;
             getForm().addWidgetUpdate(this);
@@ -138,8 +145,8 @@
     }
 
     public Widget getChild(String id) {
-        if (!widgets.hasWidget(id) && ((ContainerDefinition)definition).hasWidget(id))
{
-            ((ContainerDefinition)definition).createWidget(this, id);
+        if (!widgets.hasWidget(id) && definition.hasWidget(id)) {
+            definition.createWidget(this, id);
             Widget child = super.getChild(id);
             child.initialize();
             return child;
@@ -149,7 +156,7 @@
 
     //TODO: check further: cause the claim in the accompanied comment doesn't seem
     // to be completely correct
-    
+
     // This method is overridden to suppress output of sub-widget sax fragments.
 //    public void generateItemsSaxFragment(ContentHandler contentHandler, Locale locale)
throws SAXException {
 //        // Do nothing



Mime
View raw message