beehive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: rev 46081 - in incubator/beehive/trunk/netui/src: compiler/org/apache/beehive/netui/compiler/model pageflow/org/apache/beehive/netui/pageflow pageflow/org/apache/beehive/netui/pageflow/config
Date Wed, 15 Sep 2004 04:32:34 GMT
Author: rich
Date: Tue Sep 14 21:32:33 2004
New Revision: 46081

Added:
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowFormBeanConfig.java
Modified:
   incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/FormBeanModel.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
Log:
These are changes from Carlin Rogers related to his last submission (revision 43687).  They
fix an issue where passing a non-ActionForm-derived initialization bean to a page fails in
some cases (the bean's values do not show up when bound to from JSP tags).  From Carlin:

"- A management issue with form beans not derived from ActionForm,
utilizing AnyBeanActionForm. PageFlowFormBeanConfig extends the
Struts FormBeanConfig class for the <form-bean> tag to include the
actual type for the bean to help identify it."

DRT: netui (linix)
BB: self (WinXP)



Modified: incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/FormBeanModel.java
==============================================================================
--- incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/FormBeanModel.java
(original)
+++ incubator/beehive/trunk/netui/src/compiler/org/apache/beehive/netui/compiler/model/FormBeanModel.java
Tue Sep 14 21:32:33 2004
@@ -22,6 +22,8 @@
 import java.util.List;
 
 import org.apache.beehive.netui.compiler.model.schema.struts11.FormBeanDocument;
+import org.apache.beehive.netui.compiler.model.schema.struts11.SetPropertyDocument.SetProperty;
+import static org.apache.beehive.netui.compiler.JpfLanguageConstants.PAGEFLOW_PACKAGE;
 
 
 /**
@@ -86,6 +88,8 @@
     }
 
 
+    private static final String JPF_FORM_BEAN_CONFIG_CLASSNAME = PAGEFLOW_PACKAGE + ".config.PageFlowFormBeanConfig";
+
     private String _id = "";  // NOI18N
     private String _className = null;
     private boolean _dynamic = false;
@@ -115,6 +119,14 @@
         if ( xb.getId() == null && _id != null && _id.length() > 0 )
         {
             xb.setId( _id );
+        }
+
+        if ( _actualType != null )
+        {
+            SetProperty prop = xb.addNewSetProperty();
+            prop.setProperty( "actualType" );
+            prop.setValue( _actualType );
+            xb.setClassName( JPF_FORM_BEAN_CONFIG_CLASSNAME );
         }
         
         if ( xb.getClassName() == null &&_className != null )

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
Tue Sep 14 21:32:33 2004
@@ -17,6 +17,7 @@
  */
 package org.apache.beehive.netui.pageflow;
 
+import org.apache.beehive.netui.pageflow.config.PageFlowFormBeanConfig;
 import org.apache.beehive.netui.pageflow.internal.ActionResultImpl;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
 import org.apache.beehive.netui.pageflow.scoping.ScopedRequest;
@@ -403,7 +404,7 @@
         }
     }
 
-    private static String getFormNameFromModuleConfig( ActionForm form, ModuleConfig moduleConfig
)
+    private static String getFormNameFromModuleConfig( String formBeanClassName, ModuleConfig
moduleConfig )
     {
         String modulePrefix = moduleConfig.getPrefix();
         Map< String, String > formNameMap = _formNameMaps.get( modulePrefix );  //
map of form-type-name to form-name
@@ -415,13 +416,22 @@
             
             for ( int j = 0; j < formBeans.length; ++j )
             {
-                formNameMap.put( formBeans[j].getType(), formBeans[j].getName() );
+                assert formBeans[j] != null;
+                if ( formBeans[j] instanceof PageFlowFormBeanConfig )
+                {
+                    formNameMap.put( ( ( PageFlowFormBeanConfig ) formBeans[j] ).getActualType(),
+                                     formBeans[j].getName() );
+                }
+                else
+                {
+                    formNameMap.put( formBeans[j].getType(), formBeans[j].getName() );
+                }
             }
             
             _formNameMaps.put( modulePrefix, formNameMap );
         }
         
-        return formNameMap.get( form.getClass().getName() );
+        return formNameMap.get( formBeanClassName );
     }
     
     /**
@@ -440,11 +450,12 @@
         if ( form != null )
         {
             ModuleConfig moduleConfig = mapping.getModuleConfig();
-            String formName = getFormNameFromModuleConfig( form, moduleConfig );
+            Class formClass = InternalUtils.unwrapFormBean( form ).getClass();
+            String formName = getFormNameFromModuleConfig( formClass.getName(), moduleConfig
);
             
             if ( formName == null )
             {
-                formName = getFormBeanName( form, request, false );
+                formName = getFormBeanName( formClass, request, false );
             }
             
             InternalUtils.setFormInScope( formName, form, mapping, request, overwrite );
@@ -507,15 +518,8 @@
         
         if ( doStrutsLookup )
         {       
-            FormBeanConfig[] formBeans = moduleConfig.findFormBeanConfigs();
-            
-            for ( int j = 0; j < formBeans.length; ++j )
-            {
-                if ( formBeans[j].getType().equals( formBeanClassName ) )
-                {
-                    return formBeans[j].getName();
-                }
-            }
+            String name = getFormNameFromModuleConfig( formBeanClassName, moduleConfig );
+            if ( name != null ) return name;
         }
         
         //

Added: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowFormBeanConfig.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/config/PageFlowFormBeanConfig.java
Tue Sep 14 21:32:33 2004
@@ -0,0 +1,40 @@
+/*
+ * Copyright 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.pageflow.config;
+
+import org.apache.struts.config.FormBeanConfig;
+
+
+/**
+ * Class to handle our extensions to the Struts <form-bean> tag.
+ */
+public class PageFlowFormBeanConfig extends FormBeanConfig
+{
+    private String _actualType;  // applicable for non-ActionForm-derived form types
+
+
+    public String getActualType()
+    {
+        return _actualType;
+    }
+
+    public void setActualType( String actualType )
+    {
+        _actualType = actualType;
+    }
+}

Mime
View raw message