myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r750794 - in /myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal: renderkit/core/xhtml/ ui/laf/base/xhtml/ webapp/wrappers/
Date Fri, 06 Mar 2009 07:25:33 GMT
Author: matzew
Date: Fri Mar  6 07:25:33 2009
New Revision: 750794

URL: http://svn.apache.org/viewvc?rev=750794&view=rev
Log:
TRINIDAD-1412 - commandButton, panelAccordion and processChoiceBar have limited functionality
in Non-JavaScript mobile browsers.

Thx to Mamallan Uthaman for the patch

Modified:
    myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandButtonRenderer.java
    myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/PanelAccordionRenderer.java
    myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlConstants.java
    myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/OptionContainerRenderer.java
    myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/ProcessChoiceBarRenderer.java
    myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/ProcessUtils.java
    myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/BasicHTMLBrowserRequestWrapper.java

Modified: myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandButtonRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandButtonRenderer.java?rev=750794&r1=750793&r2=750794&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandButtonRenderer.java
(original)
+++ myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandButtonRenderer.java
Fri Mar  6 07:25:33 2009
@@ -165,27 +165,28 @@
       } 
       else
       {
-        if (icon != null)
-        {
-          renderEncodedResourceURI(context, "src", icon);
-        }
-        
         // For Non-JavaScript browsers, encode the name attribute with the 
         // parameter name and value thus it would enable the browsers to 
         // include the name of this element in its payLoad if it submits the
         // page.
          
-        else if(!supportsScripting(arc))
+        if(!supportsScripting(arc))
         {
-          rw.writeAttribute("name", XhtmlUtils.getEncodedParameter
-                                      (XhtmlConstants.SOURCE_PARAM)
-                                       + clientId, null);
-
-          rw.writeAttribute("value", text, "text");
+          String encodingKey = 
+                        (icon != null)? XhtmlConstants.NO_JS_INPUT_IMAGE_KEY
+                                      : XhtmlConstants.NO_JS_PARAMETER_KEY;
+                                      
+          rw.writeAttribute("name", XhtmlConstants.SOURCE_PARAM + encodingKey
+                                    + clientId, null);
+        }
+                
+        if (icon != null)
+        {
+          renderEncodedResourceURI(context, "src", icon);
         }
         else
         {
-          rw.writeAttribute("value", text, "text");;
+          rw.writeAttribute("value", text, "text");
         }
       }
  

Modified: myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/PanelAccordionRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/PanelAccordionRenderer.java?rev=750794&r1=750793&r2=750794&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/PanelAccordionRenderer.java
(original)
+++ myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/PanelAccordionRenderer.java
Fri Mar  6 07:25:33 2009
@@ -397,7 +397,7 @@
         
         out.writeAttribute("value", icon, null);
         
-        if (disabled)
+        if (disabled || !disclosable)
         {
           out.writeAttribute("disabled", Boolean.TRUE, "disabled");
         }

Modified: myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlConstants.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlConstants.java?rev=750794&r1=750793&r2=750794&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlConstants.java
(original)
+++ myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlConstants.java
Fri Mar  6 07:25:33 2009
@@ -305,8 +305,12 @@
 
   //Constants for Non JavaScript browser support
   public static final String NO_JS_PARAMETER_KEY = "_parameterkey";
-  public static final String NO_JS_PARAMETER_KEY_BUTTON = "go";
+  public static final String NO_JS_INPUT_IMAGE_KEY = "_inputImagekey";
   public static final String MULTIPLE_VALUE_PARAM = "multipleValueParam";
+  public static final String NO_JS_PARAMETER_KEY_BUTTON = "Go";
+  public static final String NO_JS_PARAMETER_BACK_BUTTON = "Back";
+  public static final String NO_JS_PARAMETER_NEXT_BUTTON = "Next";
+  
   public static final String NON_JS_BROWSER = "_noJavaScript";
   public static final String NON_JS_BROWSER_TRUE = "true";
   public static final String NON_JS_DETAIL_DISCLOSED_ICON = "-";

Modified: myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/OptionContainerRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/OptionContainerRenderer.java?rev=750794&r1=750793&r2=750794&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/OptionContainerRenderer.java
(original)
+++ myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/OptionContainerRenderer.java
Fri Mar  6 07:25:33 2009
@@ -468,8 +468,20 @@
       {
         value = XhtmlLafUtils.getFormEncodedValue(context, transName, value);
       }
-
-      renderValue(context, node, value);
+      
+      // In the case of Non-JavaScript browsers, skip the renderValue method 
+      // call since it appends the index of option element to the value 
+      // attribute.
+      if (!supportsScripting(context)) 
+      {
+        FacesContext fContext = context.getFacesContext();
+        ResponseWriter out = fContext.getResponseWriter();
+        out.writeAttribute("value", value, null);
+      }
+      else
+      {
+        renderValue(context, node, value);
+      }
     }
     
     protected void renderValue(

Modified: myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/ProcessChoiceBarRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/ProcessChoiceBarRenderer.java?rev=750794&r1=750793&r2=750794&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/ProcessChoiceBarRenderer.java
(original)
+++ myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/ProcessChoiceBarRenderer.java
Fri Mar  6 07:25:33 2009
@@ -28,12 +28,15 @@
 import org.apache.myfaces.trinidad.component.UIXProcess;
 import org.apache.myfaces.trinidad.component.core.layout.CorePanelButtonBar;
 
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlConstants;
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlUtils;
 import org.apache.myfaces.trinidadinternal.share.url.FormEncoder;
 import org.apache.myfaces.trinidadinternal.share.url.URLEncoder;
 import org.apache.myfaces.trinidadinternal.ui.MutableUINode;
 import org.apache.myfaces.trinidadinternal.ui.NodeUtils;
-import org.apache.myfaces.trinidadinternal.ui.UIXRenderingContext;
+import org.apache.myfaces.trinidadinternal.ui.UIConstants;
 import org.apache.myfaces.trinidadinternal.ui.UINode;
+import org.apache.myfaces.trinidadinternal.ui.UIXRenderingContext;
 import org.apache.myfaces.trinidadinternal.ui.beans.MarlinBean;
 import org.apache.myfaces.trinidadinternal.ui.data.BoundValue;
 import org.apache.myfaces.trinidadinternal.ui.data.bind.AccessKeyBoundValue;
@@ -284,22 +287,6 @@
                                     null,
                                     null));
       }
-      else
-      {
-        backButton = ProcessUtils.createSubmitButton(context,
-                                                     buttonTextBV,
-                                                     buttonAccessKeyBV,
-                                                     null,
-                                                     formName,
-                                                     false,
-                                                     EVENT_PARAM,
-                                                     SOURCE_PARAM,
-                                                     nameString,
-                                                     VALUE_PARAM,
-                                                     selectedIndex - 1,
-                                                     SIZE_PARAM,
-                                                     0);
-      }
     }
 
     UINode nextButton = null;
@@ -360,27 +347,28 @@
           mutableNextButton.setID(buttonID);
         }
         nextButton = mutableNextButton;
+        context.setLocalProperty(_NEXT_BUTTON_KEY, nextButton);
       }
       else
       {
-
-        nextButton = ProcessUtils.createSubmitButton(context,
-                                                     buttonTextBV,
-                                                     buttonAccessKeyBV,
-                                                     buttonID,
-                                                     formName,
-                                                     false,
-                                                     EVENT_PARAM,
-                                                     SOURCE_PARAM,
-                                                     nameString,
-                                                     VALUE_PARAM,
-                                                     selectedIndex + 1,
-                                                     SIZE_PARAM,
-                                                     1);
+        // For Non-JavaScript browsers, encode the parameter name and value
+        // pairs required for the next button's funtionality. This encoded  
+        // value would be used as the name attribute of the element that    
+        // would be rendered for the next button's funtionality.
+        String nameAttri = XhtmlUtils.getEncodedNameAttribute (
+                             // Array should be in the order of parameter 
+                             // name and value pair
+                                 new String[]{SOURCE_PARAM,
+                                              nameString,
+                                              EVENT_PARAM,
+                                              UIConstants.GOTO_EVENT,
+                                              VALUE_PARAM,
+                                              Long.toString(selectedIndex + 1),
+                                              SIZE_PARAM,
+                                              Integer.toString(1)});
+                                                          
+        context.setLocalProperty(_NON_JS_NEXT_BUTTON_NAME_ATTR, nameAttri);
       }
-
-      context.setLocalProperty(_NEXT_BUTTON_KEY, nextButton);
-
     }
 
     // start the rendering
@@ -403,7 +391,34 @@
     if (showBackButton)
     {
 
-      backButton.render(context);
+      if (supportsScripting)
+      {
+        backButton.render(context);
+      } 
+      else
+      {
+        // For Non-JavaScript browsers, render an input element(type= submit)
+        // to submit the page. The name attribute of this element is encoded 
+        // with parameter name and value pairs thus it would enable browsers
+        // to include the name of this element in its payLoad if it submits the
+        // page.
+        String nameAttri = XhtmlUtils.getEncodedNameAttribute (
+                            // Array should be in the order of parameter name 
+                            // and value pair
+                               new String[]{SOURCE_PARAM,
+                                            nameString,
+                                            EVENT_PARAM,
+                                            UIConstants.GOTO_EVENT,
+                                            VALUE_PARAM,
+                                            Long.toString(selectedIndex - 1),
+                                            SIZE_PARAM,
+                                            Integer.toString(0)});
+                                                   
+        _renderSubmitButtonNonJSBrowser(
+                             context, 
+                             XhtmlConstants.NO_JS_PARAMETER_BACK_BUTTON, 
+                             nameAttri );
+      }
       writer.endElement("td");
 
       _renderSpacerCell(context);
@@ -448,12 +463,14 @@
     UINode           node
     ) throws IOException
   {
+    // start rendering
+    ResponseWriter writer = context.getResponseWriter();
+    boolean renderAsTable = _renderAsTable(context, node);
+    
+    if (supportsScripting(context))
+    {
       UINode nextButton =
                     (UINode)context.getLocalProperty(0,_NEXT_BUTTON_KEY, null);
-
-      // start rendering
-      ResponseWriter writer = context.getResponseWriter();
-      boolean renderAsTable = _renderAsTable(context, node);
       // don't render the next button on last step
       if (nextButton != null)
       {
@@ -467,14 +484,59 @@
         context.setLocalProperty(_NEXT_BUTTON_KEY, null);
 
       }
-
+    }
+    else  
+    {
       writer.endElement("td");
-
-      if (renderAsTable)
+      writer.startElement("td", null);
+      
+      // For Non-JavaScript browsers, render an input element(type= submit)
+      // to submit the page. The name attribute of this element is encoded 
+      // with parameter name and value pairs thus it would enable browsers
+      // to include the name of this element in its payLoad if it submits the
+      // page.
+      String nameAttri = 
+               XhtmlUtils.getEncodedNameAttribute (
+               // Array should be in the order of parameter name and value pair
+                      new String[]{ XhtmlConstants.MULTIPLE_VALUE_PARAM,
+                                    BaseLafUtils.getStringAttributeValue
+                                    (context, node, NAME_ATTR)});
+
+      _renderSubmitButtonNonJSBrowser(
+                           context, 
+                           XhtmlConstants.NO_JS_PARAMETER_KEY_BUTTON, 
+                           nameAttri);
+      
+      String nextButtonNameAttr =
+                         (String)context.getLocalProperty(
+                                 0, _NON_JS_NEXT_BUTTON_NAME_ATTR, null);
+                                  
+      if (nextButtonNameAttr != null)
       {
-        writer.endElement("tr");
-        writer.endElement("table");
+        
+        writer.endElement("td");
+       
+        _renderSpacerCell(context);
+       
+        writer.startElement("td", null);
+       
+        _renderSubmitButtonNonJSBrowser(
+                            context, 
+                            XhtmlConstants.NO_JS_PARAMETER_NEXT_BUTTON, 
+                            nextButtonNameAttr );
+                                       
+        context.setLocalProperty(_NON_JS_NEXT_BUTTON_NAME_ATTR, null);
+        
       }
+    }
+    
+    writer.endElement("td");
+
+    if (renderAsTable)
+    {
+      writer.endElement("tr");
+      writer.endElement("table");
+    }
 
   }
 
@@ -722,6 +784,32 @@
 
   }
 
+  /**
+    * @param context a <code>UIXRenderingContext</code>
+    * @param valueAttri a <code>String</code> it is the value attribute  
+    *  of the submit button 
+    * @param nameAttri  a <code>String</code> it is the name attribute  
+    *  of the submit button 
+    *
+    * This method renders an input element(type= submit) to submit the page.
+    * The name attribute of this element is encoded with parameter name and
+    * value pairs thus it would enable browsers to include the name of this 
+    * element in its payLoad if it submits the page.
+    *
+    */
+  private void _renderSubmitButtonNonJSBrowser(
+    UIXRenderingContext context,
+    String         valueAttri,
+    String         nameAttri
+    ) throws IOException
+  {
+    ResponseWriter writer = context.getResponseWriter();
+    writer.startElement("input", null);
+    renderAttribute(context, "type", "submit");
+    renderAttribute(context, "value", valueAttri);
+    renderAttribute(context, "name", nameAttri);
+    writer.endElement("input");
+  }
 
   //
   // Private variables
@@ -737,5 +825,6 @@
 
   static private final Object _NEXT_BUTTON_KEY = new Object();
   static private final Object _NEW_PATH_KEY = new Object();
+  static private final Object _NON_JS_NEXT_BUTTON_NAME_ATTR = new Object();
 
 }

Modified: myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/ProcessUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/ProcessUtils.java?rev=750794&r1=750793&r2=750794&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/ProcessUtils.java
(original)
+++ myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/ProcessUtils.java
Fri Mar  6 07:25:33 2009
@@ -73,20 +73,6 @@
     submitButton.setAttributeValue(UIConstants.TEXT_ATTR, buttonText);
     submitButton.setAttributeValue(UIConstants.ACCESS_KEY_ATTR,
                                    buttonAccessKey);
-                                   
-    String nameAttri = XhtmlUtils.getEncodedNameAttribute (
-                      //Array should be in the order of parameter name and value pair
-                              new String[]{sourceKey,
-                                           source,
-                                           eventKey,
-                                           UIConstants.GOTO_EVENT,
-                                           valueKey,
-                                           Long.toString(value),
-                                           sizeKey,
-                                           Integer.toString(size)});
-                                               
-    submitButton.setAttributeValue(UIConstants.NAME_ATTR, nameAttri);
-    
     return submitButton;
   }
 

Modified: myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/BasicHTMLBrowserRequestWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/BasicHTMLBrowserRequestWrapper.java?rev=750794&r1=750793&r2=750794&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/BasicHTMLBrowserRequestWrapper.java
(original)
+++ myfaces/trinidad/branches/1.2.11.2-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/wrappers/BasicHTMLBrowserRequestWrapper.java
Fri Mar  6 07:25:33 2009
@@ -67,13 +67,30 @@
     while (enumeration.hasMoreElements() && findSubmit)
     {
       paramName = (String)enumeration.nextElement();
-      //Search for name attribute that contains encoded parameters 
+      
+      // Search for name attribute that contains encoded parameters 
       if (paramName.indexOf(XhtmlConstants.NO_JS_PARAMETER_KEY) != -1)
       {
         encodedParameterName = paramName;
         paramDetail = paramName.split(XhtmlConstants.NO_JS_PARAMETER_KEY);
         findSubmit = false;
       }
+      
+      // If a page is submitted by an input element of type 'image', browser 
+      // will generate two parameter names from the element's name attribute  
+      // that contains encoded parameters. Each of the parameter name generated 
+      // represents the coordinate of the image that was activated. Example,
+      // if the name attribute of the element is 'paramName', browser will 
+      // create two parameter names like 'paramName.x' and 'paramName.y'.
+      else if (paramName.indexOf(XhtmlConstants.NO_JS_INPUT_IMAGE_KEY) != -1)
+      {
+        encodedParameterName = paramName;
+        
+        // Remove '.x' or '.y' from the parameter name before decoding
+        paramName = paramName.substring(0, paramName.length()-2);  
+        paramDetail = paramName.split(XhtmlConstants.NO_JS_INPUT_IMAGE_KEY);
+        findSubmit = false;
+      }
     }
     
     decodedParamMap = new HashMap<String, String[]>();
@@ -198,6 +215,3 @@
   // This map is the integration of decodedParamMap and payLoad's parameterMap
   private Map<String, String[]> modifiableParameterMap;  
 }
-
-
-



Mime
View raw message