You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2011/04/28 16:11:52 UTC

svn commit: r1097467 - in /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/popup: AbstractHtmlPopup.java HtmlPopupRenderer.java

Author: lu4242
Date: Thu Apr 28 14:11:52 2011
New Revision: 1097467

URL: http://svn.apache.org/viewvc?rev=1097467&view=rev
Log:
TOMAHAWK-1451 [myfaces-example-simple-1.1.9] Popup example doesn't work with Mojarra 1.2/2.0.0

Modified:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/popup/AbstractHtmlPopup.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/popup/HtmlPopupRenderer.java

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/popup/AbstractHtmlPopup.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/popup/AbstractHtmlPopup.java?rev=1097467&r1=1097466&r2=1097467&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/popup/AbstractHtmlPopup.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/popup/AbstractHtmlPopup.java Thu Apr 28 14:11:52 2011
@@ -112,4 +112,16 @@ public abstract class AbstractHtmlPopup
      * @JSFProperty
      */
     public abstract Boolean getClosePopupOnExitingPopup();
+    
+    /**
+     * The type of layout markup to use when rendering this group. If the value is "block"
+     * the renderer must produce an HTML "div" element. If the value is "none", no tag is
+     * rendered on the output and instead, onmouseover and onmouseout properties are modified
+     * for children components. Otherwise HTML "span" element must be produced.
+     *
+     * @JSFProperty
+     * @return  the new layout value
+     */
+    public abstract String getLayout();
+    
 }

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/popup/HtmlPopupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/popup/HtmlPopupRenderer.java?rev=1097467&r1=1097466&r2=1097467&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/popup/HtmlPopupRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/popup/HtmlPopupRenderer.java Thu Apr 28 14:11:52 2011
@@ -18,19 +18,20 @@
  */
 package org.apache.myfaces.custom.popup;
 
+import java.io.IOException;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
 import org.apache.myfaces.renderkit.html.util.AddResource;
 import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.util.JavascriptUtils;
 import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import java.io.IOException;
-import java.util.List;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.util.JavascriptUtils;
 
 /**
  * @JSFRenderer
@@ -46,6 +47,11 @@ public class HtmlPopupRenderer
 {
     public static final String RENDERER_TYPE = "org.apache.myfaces.Popup";
     //private static final Log log = LogFactory.getLog(HtmlListRenderer.class);
+    
+    private static final String LAYOUT_BLOCK = "block";
+    private static final String LAYOUT_DIV = "div";
+    private static final String LAYOUT_SPAN = "span";
+    private static final String LAYOUT_NONE = "none";
 
     public boolean getRendersChildren()
     {
@@ -76,13 +82,42 @@ public class HtmlPopupRenderer
 
         //writeMouseOverAndOutAttribs(popupId, popupFacet.getChildren());
 
-        writeMouseOverAttribs(popupId, uiComponent.getChildren(),
-            popup.getClosePopupOnExitingElement()==null ||
-                    popup.getClosePopupOnExitingElement().booleanValue());
-
-        RendererUtils.renderChildren(facesContext, uiComponent);
-
         ResponseWriter writer = facesContext.getResponseWriter();
+        
+        String layout = popup.getLayout();
+        
+        if (LAYOUT_BLOCK.equals(layout) || LAYOUT_DIV.equals(layout))
+        {
+            writer.startElement(HTML.DIV_ELEM, popup);
+            writer.writeAttribute(HTML.ONMOUSEOVER_ATTR, popupId + ".display(event);", null);
+            writer.writeAttribute(HTML.ONMOUSEOUT_ATTR, popupId + ".hide(event);", null);
+        }
+        else if (LAYOUT_NONE.equals(layout))
+        {
+            writeMouseOverAttribs(popupId, uiComponent.getChildren(),
+                    popup.getClosePopupOnExitingElement()==null ||
+                            popup.getClosePopupOnExitingElement().booleanValue());
+        }
+        else
+        {
+            writer.startElement(HTML.SPAN_ELEM, popup);
+            writer.writeAttribute(HTML.ONMOUSEOVER_ATTR, popupId + ".display(event);", null);
+            writer.writeAttribute(HTML.ONMOUSEOUT_ATTR, popupId + ".hide(event);", null);
+        }
+        
+        RendererUtils.renderChildren(facesContext, uiComponent);
+        
+        if (LAYOUT_BLOCK.equals(layout) || LAYOUT_DIV.equals(layout))
+        {
+            writer.endElement(HTML.DIV_ELEM);
+        }
+        else if (LAYOUT_NONE.equals(layout))
+        {
+        }
+        else
+        {
+            writer.endElement(HTML.SPAN_ELEM);
+        }
 
         writer.startElement(HTML.DIV_ELEM, popup);
         writer.writeAttribute(HTML.STYLE_ATTR,(popup.getStyle()!=null?(popup.getStyle()+