You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by do...@apache.org on 2004/11/17 22:46:43 UTC

svn commit: rev 76177 - in incubator/beehive/trunk/netui/src: pageflow/org/apache/beehive/netui/pageflow tags-html/org/apache/beehive/netui/tags/html tags-html/org/apache/beehive/netui/tags/naming

Author: dolander
Date: Wed Nov 17 13:46:42 2004
New Revision: 76177

Modified:
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/IdMapper.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ProcessPopulate.java
   incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/RequestParameterHandler.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/FileUpload.java
   incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Hidden.java
   incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlDataSourceTag.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/tags-html/org/apache/beehive/netui/tags/html/TextArea.java
   incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/TextBox.java
   incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/naming/PrefixNameInterceptor.java
Log:
Rework the processRequest path so that the checkbox tag can access the hidden field when ID Transparency is on.
ID Transparency is still turned off.




Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/IdMapper.java
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/IdMapper.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/IdMapper.java	Wed Nov 17 13:46:42 2004
@@ -49,7 +49,7 @@
             HashMap map = new HashMap(expr.length * 2 + 3);
             for (int i = 1; i < expr.length; i += 2) {
                 map.put(expr[i - 1], expr[i]);
-                System.err.println("Expand key '" + expr[i-1] + "' value '" + expr[i] + "'");
+                //System.err.println("Expand key '" + expr[i-1] + "' value '" + expr[i] + "'");
             }
             return map;
         }

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ProcessPopulate.java
==============================================================================
--- 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	Wed Nov 17 13:46:42 2004
@@ -201,11 +201,12 @@
                 expr = (String) expressionMap.get(key);
                 if (expr == null)
                     expr = key;
+                //System.err.println("Expr: '" + expr + "' key: '" + key + "'");
             }
             else {
                 expr = key;
+                //System.err.println("NonExpr: '" + key + "'");
             }
-            //System.err.println("Expr: '" + expr + "' key: '" + key + "'");
 
             if (_logger.isDebugEnabled())
                 _logger.debug("key: " + key + " value type: " + params.get(key).getClass().getName() + " value: " + params.get(key));
@@ -225,7 +226,7 @@
                         {
                             if (_logger.isDebugEnabled()) _logger.debug("Found an expression requiring a TAG HANDLER");
 
-                            ExpressionUpdateNode node = doTagHandler(expr, values, request);
+                            ExpressionUpdateNode node = doTagHandler(key, expr, values, request);
 
                             expr = node.expression;
                             values = node.values;
@@ -287,6 +288,7 @@
             catch (Exception e)
             {
                 String s = Bundle.getString("ProcessPopulate_exprUpdateError", new Object[]{expr, e});
+                //e.printStackTrace();
 
                 System.err.println(s);
 
@@ -306,24 +308,24 @@
      * @param key the request key that is being processed
      * @param request the ServletRequest object representing this request
      */
-    static final ExpressionUpdateNode doTagHandler(String key, String[] values, HttpServletRequest request)
+    static final ExpressionUpdateNode doTagHandler(String key, String expression, String[] values, HttpServletRequest request)
     {
         // not sure if this array will be mutable.  don't want to find out at this point.
         String[] _values = values;
 
         // key might be mangled here; make a copy
-        String expr = key;
+        String expr = expression;
 
         if(_logger.isDebugEnabled()) _logger.debug("Found prefixed tag; handlerName: " + key.substring(WLW_TAG_HANDLER_PREFIX.length(), key.indexOf(WLW_TAG_HANDLER_SUFFIX)));
             
-        String handlerName = key.substring(WLW_TAG_HANDLER_PREFIX.length(), key.indexOf(WLW_TAG_HANDLER_SUFFIX));
+        String handlerName = expression.substring(WLW_TAG_HANDLER_PREFIX.length(), expression.indexOf(WLW_TAG_HANDLER_SUFFIX));
         
         // execute callback to parameter handler.  Generally, these are tags.
         RequestParameterHandler handler = (RequestParameterHandler)handlerMap.get(handlerName);
         
         if(handler != null)
         {
-            expr = key.substring(key.indexOf(WLW_TAG_HANDLER_SUFFIX)+1);
+            expr = expression.substring(expression.indexOf(WLW_TAG_HANDLER_SUFFIX)+1);
             
             if(_logger.isDebugEnabled()) _logger.debug("found handler for prefix \"" + handlerName + "\" type: " + 
                                    (handler != null ? handler.getClass().getName() : null) + "\n\t" + 
@@ -334,7 +336,7 @@
             node.values = _values;
             
             // request, request key, the standalone expression (may have other stuff bracketing the expression
-            handler.process(request, key, node);
+            handler.process(request, key, expression, node);
             
             return node;
         }

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/RequestParameterHandler.java
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/RequestParameterHandler.java	(original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/RequestParameterHandler.java	Wed Nov 17 13:46:42 2004
@@ -29,5 +29,5 @@
  */
 public interface RequestParameterHandler
 {
-    public void process(HttpServletRequest request, String key, ProcessPopulate.ExpressionUpdateNode node);
+    public void process(HttpServletRequest request, String key, String expr, ProcessPopulate.ExpressionUpdateNode node);
 }

Modified: 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/CheckBox.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/CheckBox.java	Wed Nov 17 13:46:42 2004
@@ -116,8 +116,10 @@
         /**
          * Determines the current state of the CheckBox (true or false) based on the Request.
          */
-        public void process(HttpServletRequest request, String key, ProcessPopulate.ExpressionUpdateNode node)
+        public void process(HttpServletRequest request, String key, String expr, ProcessPopulate.ExpressionUpdateNode node)
         {
+            //System.err.println("CheckBox-process: '" + key + "' expr: '" + expr + "'");
+
             String returnVal = null;
             if (!key.endsWith(OLDVALUE_SUFFIX)) {
                 //This checkbox is true and should stay that way
@@ -135,10 +137,13 @@
                 }
             }
 
+            //System.err.println("node.expression:" + node.expression);
+
             if (node.expression.endsWith(OLDVALUE_SUFFIX)) {
                 node.expression = node.expression.substring(0, node.expression.indexOf(OLDVALUE_SUFFIX));
 
             }
+            //System.err.println("Return Value:" + returnVal);
             node.values = new String[]{returnVal};
 
             if (logger.isDebugEnabled()) {
@@ -257,7 +262,7 @@
         if (hasErrors())
             return reportAndExit(EVAL_PAGE);
 
-        String realName = doNaming();
+        String realName = doNaming(OLDVALUE_SUFFIX);
         if (hasErrors())
             return reportAndExit(EVAL_PAGE);
 
@@ -291,7 +296,7 @@
         String oldValue = req.getParameter(realName);
         WriteRenderAppender writer = new WriteRenderAppender(pageContext);
 
-        // if the checkbox is disabled we need to not right out the hidden
+        // if the checkbox is disabled we need to not write out the hidden
         // field because it can cause the default state to change from
         // true to false.  Disabled check boxes do not postback.
         if (!_state.disabled) {

Modified: 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/CheckBoxGroup.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/CheckBoxGroup.java	Wed Nov 17 13:46:42 2004
@@ -184,7 +184,7 @@
         /**
          * Determines the current state of the CheckBoxGroup based on the Request.
          */
-        public void process(HttpServletRequest request, String key, ProcessPopulate.ExpressionUpdateNode node)
+        public void process(HttpServletRequest request, String key, String expr, ProcessPopulate.ExpressionUpdateNode node)
         {
             String[] returnArray = null;
 

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FileUpload.java
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FileUpload.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/FileUpload.java	Wed Nov 17 13:46:42 2004
@@ -229,7 +229,7 @@
         String idScript = null;
 
         // Create the state for the input tag.
-        String realName = doNaming();
+        String realName = doNaming(null);
         if (_dataSource != null) {
             _state.name = realName;
         }

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Hidden.java
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Hidden.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Hidden.java	Wed Nov 17 13:46:42 2004
@@ -160,7 +160,7 @@
 
         // Create an appropriate "input" element based on our parameters
         if (_dataSource != null) {
-            name = doNaming();
+            name = doNaming(null);
             _state.name = name;
         }
 
@@ -176,7 +176,7 @@
             _state.value = "";
 
         // output the id
-        _state.name = doNaming();
+        //_state.name = doNaming();
 
         // we assume that tagId will over have override id if both
         // are defined.

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlDataSourceTag.java
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlDataSourceTag.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlDataSourceTag.java	Wed Nov 17 13:46:42 2004
@@ -110,22 +110,33 @@
     }
 
     /**
-     * @return String
+     * This method will create the name of the form element.  The HTML tags support two forms of names,
+     * if ID transparency is turned on, then we will either use the id of the tag or generate a unique name.
+     * If ID transparency is turned off, then we use the expression as the name of the element.  In some cases,
+     * a tag may need to write out a hidden field with additional information.  If the
+     * hiddenSuffix is passed and ID transarency is on, the "name" + hiddenSuffix will also
+     * be written to the ID map.
+     * @param hiddenSuffix a value of a hidden field that will be written to the
+     * ID map if an ID Map is being generated.
+     * @return String the name of this form element.
      */
-    protected String doNaming()
+    protected String doNaming(String hiddenSuffix)
             throws JspException
     {
         assert (_dataSource != null) : "dataSource is Null";
 
         String datasource = "{" + _dataSource + "}";
-        String name = applyNamingChain(datasource);
+        String expr = applyNamingChain(datasource);
+        String name = expr;
         IHtmlIdWriter idWriter = getNearestIdWriter();
         if (idWriter != null) {
             String id = getTagId();
             if (id == null) {
                 id = idWriter.getNextId();
             }
-            name = idWriter.writeId(id, name);
+            name = idWriter.writeId(id, expr);
+            if (hiddenSuffix != null)
+                idWriter.writeId(id + hiddenSuffix, expr);
         }
         return name;
 

Modified: 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/RadioButtonGroup.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RadioButtonGroup.java	Wed Nov 17 13:46:42 2004
@@ -183,7 +183,7 @@
             implements org.apache.beehive.netui.pageflow.RequestParameterHandler
     {
         public void process(javax.servlet.http.HttpServletRequest request, String key,
-                            ProcessPopulate.ExpressionUpdateNode node)
+                            String expr, ProcessPopulate.ExpressionUpdateNode node)
         {
             if (logger.isDebugEnabled()) {
                 logger.debug("*********************************************\n" +

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Select.java
==============================================================================
--- 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	Wed Nov 17 13:46:42 2004
@@ -271,7 +271,7 @@
             implements RequestParameterHandler
     {
         public void process(javax.servlet.http.HttpServletRequest request, String key,
-                            ProcessPopulate.ExpressionUpdateNode node)
+                            String expr, ProcessPopulate.ExpressionUpdateNode node)
         {
             String[] returnArray = null;
 
@@ -727,7 +727,7 @@
         _state.disabled = isDisabled();
 
         //Create hidden field for state tracking
-        String realName = doNaming();
+        String realName = doNaming(null);
         if (hasErrors())
             return reportAndExit(EVAL_PAGE);
 

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/TextArea.java
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/TextArea.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/TextArea.java	Wed Nov 17 13:46:42 2004
@@ -169,7 +169,7 @@
         assert(textObject != null);
 
         // setup the rest of the state.
-        _state.name = doNaming();
+        _state.name = doNaming(null);
 
         scriptId = renderTagId(_state, _state.name, false, true);
         _state.disabled = isDisabled();

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/TextBox.java
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/TextBox.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/TextBox.java	Wed Nov 17 13:46:42 2004
@@ -246,7 +246,7 @@
         }
 
         // Create the state for the input tag
-        _state.name = doNaming();
+        _state.name = doNaming(null);
         scriptId = renderTagId(_state, _state.name, false, true);
         _state.disabled = isDisabled();
 

Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/naming/PrefixNameInterceptor.java
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/naming/PrefixNameInterceptor.java	(original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/naming/PrefixNameInterceptor.java	Wed Nov 17 13:46:42 2004
@@ -29,7 +29,7 @@
  * in order to update a bean property.  This preprocessing is done by
  * implementing a handler implementing the interface
  * {@link org.apache.beehive.netui.pageflow.RequestParameterHandler}, registering
- * this interface with the {@link org.apache.beehive.netui.pageflow.ProcessPopulate#registerPrefixHandler(String, RequestParameterHandler)}
+ * this interface with the {@link org.apache.beehive.netui.pageflow.ProcessPopulate#registerPrefixHandler(String, org.apache.beehive.netui.pageflow.RequestParameterHandler)}
  * method, and adding a prefix which references this RequestParameterHandler to the
  * name of each paramter that should be handled by the implementation before
  * updating the bean property.