Author: dolander
Date: Thu Apr  7 07:56:01 2005
New Revision: 160406

URL: http://svn.apache.org/viewcvs?view=rev&rev=160406
Log:
This checkin will register all of the prefix handlers in the tags
inside of the PageFlow Context Listener.



Modified:
    
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java
    
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ProcessPopulate.java
    
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/CheckBox.java
    
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/CheckBoxGroup.java
    
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RadioButtonGroup.java
    
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Select.java
    incubator/beehive/trunk/netui/src/util/beehive-netui-config-default.xml
    incubator/beehive/trunk/netui/src/util/schema/netui-config/netui-config.xsd

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java?view=diff&r1=160405&r2=160406
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java
 Thu Apr  7 07:56:01 2005
@@ -21,20 +21,20 @@
 
 //internal imports
 import org.apache.beehive.netui.core.urltemplates.URLTemplateDescriptor;
-import org.apache.beehive.netui.pageflow.internal.InternalConstants;
+import org.apache.beehive.netui.pageflow.handler.Handlers;
 import org.apache.beehive.netui.pageflow.internal.AdapterManager;
+import org.apache.beehive.netui.pageflow.internal.InternalConstants;
 import org.apache.beehive.netui.pageflow.internal.LegacySettings;
-import org.apache.beehive.netui.pageflow.handler.Handlers;
-import org.apache.beehive.netui.util.config.ConfigUtil;
 import org.apache.beehive.netui.util.config.ConfigInitializationException;
+import org.apache.beehive.netui.util.config.ConfigUtil;
+import org.apache.beehive.netui.util.config.bean.PrefixHandlers;
 import org.apache.beehive.netui.util.logging.Logger;
 
-//external imports
-import javax.servlet.ServletContextListener;
-import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContext;
-import java.io.InputStream;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
 import java.io.IOException;
+import java.io.InputStream;
 
 import static 
org.apache.beehive.netui.pageflow.internal.InternalConstants.NETUI_CONFIG_PATH;
 
@@ -100,5 +100,47 @@
         LegacySettings.init( servletContext );
         Handlers.init( servletContext );
         URLTemplateDescriptor.getInstance().load( servletContext );
+        initPrefixHandlers();
+    }
+
+    /**
+     * This method will initialize all of the PrefixHandlers registered in the 
netui config.
+     * The prefix handlers are registered with ProcessPopulate and are 
typically implemented as
+     * public inner classes in the tags that require prefix handlers.
+     */
+    private static void initPrefixHandlers()
+    {
+        PrefixHandlers ph = ConfigUtil.getConfig().getPrefixHandlers();
+        if (ph == null)
+            return;
+        PrefixHandlers.PrefixHandler[] prefixHandlers = 
ph.getPrefixHandlerArray();
+        if (prefixHandlers != null) {
+            for (int i=0;i<prefixHandlers.length;i++) {
+                try {
+                    Class prefixClass = 
Class.forName(prefixHandlers[i].getHandlerClass());
+                    String name = prefixHandlers[i].getName();
+                    if (name == null || name.equals("")) {
+                        _log.warn("The name for the prefix handler '" + 
prefixHandlers[i].getHandlerClass() + "' must not be null");
+                        continue;
+                    }
+                    Object o = prefixClass.newInstance();
+                    if (!(o instanceof RequestParameterHandler))  {
+                        _log.warn("The class '" + 
prefixHandlers[i].getHandlerClass() + "' must be an instance of 
RequestParameterHandler");
+                        continue;
+                    }
+                    ProcessPopulate.registerPrefixHandler(name, 
(RequestParameterHandler) o);
+                }
+                catch (ClassNotFoundException e) {
+                    _log.warn("Class '" + prefixHandlers[i].getHandlerClass() 
+ "' not found", e);
+                }
+                catch (IllegalAccessException e) {
+                    _log.warn("Illegal access on Class '" + 
prefixHandlers[i].getHandlerClass() + "'", e);
+
+                }
+                catch (InstantiationException e) {
+                    _log.warn("InstantiationException on Class '" + 
prefixHandlers[i].getHandlerClass() + "'", e.getCause());
+                }
+            }
+        }
     }
 }

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ProcessPopulate.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ProcessPopulate.java?view=diff&r1=160405&r2=160406
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ProcessPopulate.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ProcessPopulate.java
 Thu Apr  7 07:56:01 2005
@@ -117,7 +117,8 @@
 
             if(_logger.isInfoEnabled()) _logger.info(msg);
 
-            handlerMap.put(prefix, handler);
+            if (handlerMap.get(prefix) == null)
+                handlerMap.put(prefix, handler);
         }
     }
 

Modified: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/CheckBox.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/CheckBox.java?view=diff&r1=160405&r2=160406
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/CheckBox.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/CheckBox.java
 Thu Apr  7 07:56:01 2005
@@ -111,7 +111,7 @@
     /**
      * The handler for naming and indexing the CheckBox.
      */
-    private static class CheckBoxPrefixHandler
+    public static class CheckBoxPrefixHandler
             implements RequestParameterHandler
     {
         /**

Modified: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/CheckBoxGroup.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/CheckBoxGroup.java?view=diff&r1=160405&r2=160406
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/CheckBoxGroup.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/CheckBoxGroup.java
 Thu Apr  7 07:56:01 2005
@@ -180,7 +180,7 @@
     /**
      * The handler for naming and indexing the CheckBoxGroup.
      */
-    private static class CheckboxGroupPrefixHandler
+    public static class CheckboxGroupPrefixHandler
             implements 
org.apache.beehive.netui.pageflow.RequestParameterHandler
     {
         /**

Modified: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RadioButtonGroup.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RadioButtonGroup.java?view=diff&r1=160405&r2=160406
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RadioButtonGroup.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RadioButtonGroup.java
 Thu Apr  7 07:56:01 2005
@@ -179,7 +179,7 @@
     /**
      * The handler for naming and indexing the RadioButtonGroup.
      */
-    private static class RadioButtonGroupPrefixHandler
+    public static class RadioButtonGroupPrefixHandler
             implements 
org.apache.beehive.netui.pageflow.RequestParameterHandler
     {
         public void process(javax.servlet.http.HttpServletRequest request, 
String key,

Modified: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Select.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Select.java?view=diff&r1=160405&r2=160406
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Select.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Select.java
 Thu Apr  7 07:56:01 2005
@@ -304,7 +304,7 @@
 
     /**
      */
-    private static class SelectPrefixHandler
+    public static class SelectPrefixHandler
             implements RequestParameterHandler
     {
         public void process(javax.servlet.http.HttpServletRequest request, 
String key,

Modified: 
incubator/beehive/trunk/netui/src/util/beehive-netui-config-default.xml
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/beehive-netui-config-default.xml?view=diff&r1=160405&r2=160406
==============================================================================
--- incubator/beehive/trunk/netui/src/util/beehive-netui-config-default.xml 
(original)
+++ incubator/beehive/trunk/netui/src/util/beehive-netui-config-default.xml Thu 
Apr  7 07:56:01 2005
@@ -22,5 +22,24 @@
             </request-interceptor>
         </global>
     </request-interceptors>
-    
+
+    <prefix-handlers>
+        <prefix-handler>
+            <name>checkbox_key</name>
+            
<handler-class>org.apache.beehive.netui.tags.html.CheckBox$CheckBoxPrefixHandler</handler-class>
+        </prefix-handler>
+        <prefix-handler>
+            <name>checkbox_group_key</name>
+            
<handler-class>org.apache.beehive.netui.tags.html.CheckBoxGroup$CheckboxGroupPrefixHandler</handler-class>
+        </prefix-handler>
+        <prefix-handler>
+            <name>radio_button_group_key</name>
+            
<handler-class>org.apache.beehive.netui.tags.html.RadioButtonGroup$RadioButtonGroupPrefixHandler</handler-class>
+        </prefix-handler>
+        <prefix-handler>
+            <name>select_key</name>
+            
<handler-class>org.apache.beehive.netui.tags.html.Select$SelectPrefixHandler</handler-class>
+        </prefix-handler>
+    </prefix-handlers>
+
 </netui-config>

Modified: 
incubator/beehive/trunk/netui/src/util/schema/netui-config/netui-config.xsd
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/schema/netui-config/netui-config.xsd?view=diff&r1=160405&r2=160406
==============================================================================
--- incubator/beehive/trunk/netui/src/util/schema/netui-config/netui-config.xsd 
(original)
+++ incubator/beehive/trunk/netui/src/util/schema/netui-config/netui-config.xsd 
Thu Apr  7 07:56:01 2005
@@ -18,6 +18,7 @@
                 <xsd:element name="jsp-tag-config" type="netui:jsp-tag-config" 
minOccurs="0" maxOccurs="1"/>
                 <xsd:element name="iterator-factories" 
type="netui:iterator-factories" minOccurs="0" maxOccurs="1"/>
                 <xsd:element name="request-interceptors" 
type="netui:request-interceptors" minOccurs="0" maxOccurs="1"/>
+                <xsd:element name="prefix-handlers" 
type="netui:prefix-handlers" minOccurs="0" maxOccurs="1" />
             </xsd:sequence>
         </xsd:complexType>
     </xsd:element>
@@ -226,6 +227,21 @@
             </xsd:element>
         </xsd:sequence>
     </xsd:complexType>
+
+    <xsd:complexType name="prefix-handlers">
+        <xsd:sequence>
+            <xsd:element name="prefix-handler" minOccurs="0" 
maxOccurs="unbounded">
+                <xsd:complexType>
+                       <xsd:sequence>
+                           <xsd:element name="name" type="xsd:string" 
minOccurs="1" maxOccurs="1"/>
+                           <xsd:element name="handler-class" type="xsd:string" 
minOccurs="1" maxOccurs="1"/>
+                       </xsd:sequence>
+                       </xsd:complexType>
+                   </xsd:element>
+        </xsd:sequence>
+    </xsd:complexType>
 </xsd:schema>
 
-       
+
+
+


Reply via email to