myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r992170 - in /myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces: component/html/ext/ renderkit/html/ext/
Date Fri, 03 Sep 2010 01:42:34 GMT
Author: lu4242
Date: Fri Sep  3 01:42:34 2010
New Revision: 992170

URL: http://svn.apache.org/viewvc?rev=992170&view=rev
Log:
TOMAHAWK-1546 Allow detailStamp to be Ajaxified using f:ajax

Added:
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTableTagHandler.java
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/HtmlDetailStampRow.java
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlDetailStampRowRenderer.java
Modified:
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/AbstractHtmlDataTable.java
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java

Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/AbstractHtmlDataTable.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/AbstractHtmlDataTable.java?rev=992170&r1=992169&r2=992170&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/AbstractHtmlDataTable.java
(original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/AbstractHtmlDataTable.java
Fri Sep  3 01:42:34 2010
@@ -85,7 +85,8 @@ import org.apache.myfaces.shared_tomahaw
 @JSFComponent(
    name = "t:dataTable",
    clazz = "org.apache.myfaces.component.html.ext.HtmlDataTable",
-   tagClass = "org.apache.myfaces.generated.taglib.html.ext.HtmlDataTableTag")
+   tagClass = "org.apache.myfaces.generated.taglib.html.ext.HtmlDataTableTag",
+   tagHandler = "org.apache.myfaces.component.html.ext.HtmlDataTableTagHandler")
 public abstract class AbstractHtmlDataTable extends HtmlDataTableHack implements UserRoleAware,
NewspaperTable
 {
     private static final Log log = LogFactory.getLog(AbstractHtmlDataTable.class);
@@ -113,6 +114,8 @@ public abstract class AbstractHtmlDataTa
 
     public static final String DETAIL_STAMP_FACET_NAME = "detailStamp";
 
+    public static final String DETAIL_STAMP_ROW_FACET_NAME = "detailStampRow";
+
     private _SerializableDataModel _preservedDataModel;
 
     private boolean _isValidChildren = true;
@@ -269,6 +272,11 @@ public abstract class AbstractHtmlDataTa
                     
                     if (!returnValue)
                     {
+                        UIComponent detailStampRowFacet = getFacet(DETAIL_STAMP_ROW_FACET_NAME);
+                        if (detailStampRowFacet != null)
+                        {
+                            returnValue = detailStampRowFacet.invokeOnComponent(context,
clientId, callback);
+                        }
                         UIComponent detailStampFacet = getFacet(DETAIL_STAMP_FACET_NAME);
                         if (detailStampFacet != null)
                         {
@@ -386,6 +394,7 @@ public abstract class AbstractHtmlDataTa
                         }
                     }
                     boolean visitDetailStamp = (getFacet(DETAIL_STAMP_FACET_NAME) != null);
+                    boolean visitDetailStampRow = (getFacet(DETAIL_STAMP_ROW_FACET_NAME)
!= null);
                     
                     // iterate over the rows
                     int rowsToProcess = getRows();
@@ -417,6 +426,14 @@ public abstract class AbstractHtmlDataTa
                                 }
                             }
                         }
+                        if (visitDetailStampRow)
+                        {
+                            UIComponent detailStampRowFacet = getFacet(DETAIL_STAMP_ROW_FACET_NAME);
+                            if (detailStampRowFacet.visitTree(context, callback))
+                            {
+                                return true;
+                            }
+                        }
                         if (visitDetailStamp)
                         {
                             UIComponent detailStampFacet = getFacet(DETAIL_STAMP_FACET_NAME);
@@ -527,6 +544,11 @@ public abstract class AbstractHtmlDataTa
         //            rowState, false);
 
         //}
+        UIComponent detailStampRowFacet = getFacet(DETAIL_STAMP_ROW_FACET_NAME);
+        if (detailStampRowFacet != null)
+        {
+            detailStampRowFacet.setId(detailStampRowFacet.getId());
+        }
 
         if (getStateHelper().get(PropertyKeys.varDetailToggler) != null)
         {

Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTableTagHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTableTagHandler.java?rev=992170&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTableTagHandler.java
(added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTableTagHandler.java
Fri Sep  3 01:42:34 2010
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.myfaces.component.html.ext;
+
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRuleset;
+
+public class HtmlDataTableTagHandler extends ComponentHandler
+{
+    
+    public HtmlDataTableTagHandler(ComponentConfig config)
+    {
+        super(config);
+    }
+    
+    @Override
+    public void onComponentCreated(FaceletContext ctx, UIComponent c,
+            UIComponent parent)
+    {
+         // Add a detailStampRow component, so detailStamp rendering will be delegated
+         // to a component that can be used in ajax.
+        UIComponent detailStampRow = ctx.getFacesContext().
+            getApplication().createComponent(ctx.getFacesContext(),
+                HtmlDetailStampRow.COMPONENT_TYPE, HtmlDetailStampRow.DEFAULT_RENDERER_TYPE);
+        detailStampRow.setId("detailStampRow");
+        c.getFacets().put(AbstractHtmlDataTable.DETAIL_STAMP_ROW_FACET_NAME, detailStampRow);
+    }
+
+    @Override
+    public void onComponentPopulated(FaceletContext ctx, UIComponent c,
+            UIComponent parent)
+    {
+        //Check and remove detailStampRow component if there is no detailStamp
+        UIComponent detailStamp = c.getFacet(AbstractHtmlDataTable.DETAIL_STAMP_FACET_NAME);
+        if (detailStamp == null)
+        {
+            UIComponent detailStampRow = c.getFacet(AbstractHtmlDataTable.DETAIL_STAMP_ROW_FACET_NAME);
+            if (detailStampRow != null)
+            {
+                c.getFacets().remove(AbstractHtmlDataTable.DETAIL_STAMP_ROW_FACET_NAME);
+            }
+        }
+    }
+
+    protected MetaRuleset createMetaRuleset(Class type)
+    {
+        return super.createMetaRuleset(type).alias("class", "styleClass");
+    }
+}

Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/HtmlDetailStampRow.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/HtmlDetailStampRow.java?rev=992170&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/HtmlDetailStampRow.java
(added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/HtmlDetailStampRow.java
Fri Sep  3 01:42:34 2010
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.myfaces.component.html.ext;
+
+import javax.faces.component.UIPanel;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
+
+@JSFComponent
+public class HtmlDetailStampRow extends UIPanel
+{
+    public static final String COMPONENT_FAMILY = "org.apache.myfaces.HtmlDetailStampRow";

+    public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlDetailStampRow";
+    public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.HtmlDetailStampRow";
+
+    public HtmlDetailStampRow()
+    {
+        setRendererType(DEFAULT_RENDERER_TYPE);
+    }
+
+    public String getFamily()
+    {
+        return COMPONENT_FAMILY;
+    }
+}

Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlDetailStampRowRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlDetailStampRowRenderer.java?rev=992170&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlDetailStampRowRenderer.java
(added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlDetailStampRowRenderer.java
Fri Sep  3 01:42:34 2010
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.myfaces.renderkit.html.ext;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
+import org.apache.myfaces.component.html.ext.AbstractHtmlDataTable;
+import org.apache.myfaces.component.html.ext.HtmlDataTable;
+import org.apache.myfaces.custom.crosstable.UIColumns;
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+
+@JSFRenderer(renderKitId = "HTML_BASIC", family = "org.apache.myfaces.HtmlDetailStampRow",
type = "org.apache.myfaces.HtmlDetailStampRow")
+public class HtmlDetailStampRowRenderer extends Renderer
+{
+
+    @Override
+    public void encodeEnd(FacesContext facesContext, UIComponent component)
+            throws IOException
+    {
+        super.encodeEnd(facesContext, component);
+        UIData uiData = (UIData) component.getParent();
+        UIComponent detailStampFacet = uiData.getFacet(AbstractHtmlDataTable.DETAIL_STAMP_FACET_NAME);
+        if (uiData instanceof HtmlDataTable) {
+            HtmlDataTable htmlDataTable = (HtmlDataTable) uiData;
+
+            if (htmlDataTable.isCurrentDetailExpanded()) {
+
+                boolean embedded = false;
+                if (detailStampFacet != null) {
+                    embedded = isEmbeddedTable(detailStampFacet);
+                }
+
+                ResponseWriter writer = facesContext.getResponseWriter();
+
+                if (!embedded) {
+                    writer.startElement(HTML.TR_ELEM, uiData);
+                    writer.writeAttribute(HTML.ID_ATTR, component.getClientId(facesContext),
null);
+                    writer.startElement(HTML.TD_ELEM, uiData);
+                    //TOMAHAWK-1087 datatable dont renders a detail correct 
+                    //if a UIColumns is used we have to count UIColumns 
+                    //elements as component.getRowCount()
+                    //instead of just get the number of children available,
+                    //so the colspan could be assigned correctly.
+                    int childCount = 0;
+                    for (Iterator childIter = uiData.getChildren().iterator();
+                        childIter.hasNext();)
+                    {
+                        UIComponent childComp = (UIComponent) childIter.next();
+                        if (childComp instanceof UIColumns)
+                        {
+                            UIColumns v = (UIColumns) childComp;
+                            childCount += v.getRowCount();
+                        }
+                        else
+                        {
+                            childCount++;
+                        }
+                    }
+                    writer.writeAttribute(HTML.COLSPAN_ATTR, new Integer(
+                            childCount), null);
+                }
+
+                if (detailStampFacet != null) {
+                    RendererUtils.renderChild(facesContext, detailStampFacet);
+                }
+
+                if (!embedded) {
+                    writer.endElement(HTML.TD_ELEM);
+                    writer.endElement(HTML.TR_ELEM);
+                }
+            }
+            else
+            {
+                boolean embedded = false;
+                if (detailStampFacet != null) {
+                    embedded = isEmbeddedTable(detailStampFacet);
+                }
+
+                ResponseWriter writer = facesContext.getResponseWriter();
+
+                if (!embedded) {
+                    writer.startElement(HTML.TR_ELEM, uiData);
+                    writer.writeAttribute(HTML.ID_ATTR, component.getClientId(facesContext),
null);
+                    writer.writeAttribute(HTML.STYLE_ATTR, "display:none", null);
+                    writer.endElement(HTML.TR_ELEM);
+                }
+            }
+        }
+    }
+    
+    protected boolean isEmbeddedTable(UIComponent uiComponent) {
+        boolean embedded = false;
+        if (uiComponent instanceof HtmlDataTable) {
+            HtmlDataTable table = (HtmlDataTable) uiComponent;
+            embedded = table.isEmbedded();
+        }
+        return embedded;
+    }
+
+    @Override
+    public boolean getRendersChildren()
+    {
+        return true;
+    }
+    
+    public void encodeChildren(FacesContext context, UIComponent component) throws IOException
+    {
+    }
+}

Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java?rev=992170&r1=992169&r2=992170&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
(original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
Fri Sep  3 01:42:34 2010
@@ -39,6 +39,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
 import org.apache.myfaces.component.NewspaperTable;
+import org.apache.myfaces.component.html.ext.AbstractHtmlDataTable;
 import org.apache.myfaces.component.html.ext.HtmlDataTable;
 import org.apache.myfaces.custom.column.HtmlColumn;
 import org.apache.myfaces.custom.column.HtmlSimpleColumn;
@@ -268,54 +269,62 @@ public class HtmlTableRenderer extends H
      * @throws IOException
      */
     private void renderDetailRow(FacesContext facesContext, UIData uiData) throws IOException
{
+        UIComponent detailStampRow = uiData.getFacet(AbstractHtmlDataTable.DETAIL_STAMP_ROW_FACET_NAME);
         UIComponent detailStampFacet = uiData.getFacet(DETAIL_STAMP_FACET_NAME);
-
-        if (uiData instanceof HtmlDataTable) {
-            HtmlDataTable htmlDataTable = (HtmlDataTable) uiData;
-
-            if (htmlDataTable.isCurrentDetailExpanded()) {
-
-                boolean embedded = false;
-                if (detailStampFacet != null) {
-                    embedded = isEmbeddedTable(detailStampFacet);
-                }
-
-                ResponseWriter writer = facesContext.getResponseWriter();
-
-                if (!embedded) {
-                    writer.startElement(HTML.TR_ELEM, uiData);
-                    writer.startElement(HTML.TD_ELEM, uiData);
-                    //TOMAHAWK-1087 datatable dont renders a detail correct 
-                    //if a UIColumns is used we have to count UIColumns 
-                    //elements as component.getRowCount()
-                    //instead of just get the number of children available,
-                    //so the colspan could be assigned correctly.
-                    int childCount = 0;
-                    for (Iterator childIter = uiData.getChildren().iterator();
-                        childIter.hasNext();)
-                    {
-                        UIComponent childComp = (UIComponent) childIter.next();
-                        if (childComp instanceof UIColumns)
-                        {
-                            UIColumns v = (UIColumns) childComp;
-                            childCount += v.getRowCount();
-                        }
-                        else
+        
+        if (detailStampRow != null && detailStampFacet != null)
+        {
+            detailStampRow.encodeAll(facesContext);
+        }
+        else
+        {
+            if (uiData instanceof HtmlDataTable) {
+                HtmlDataTable htmlDataTable = (HtmlDataTable) uiData;
+    
+                if (htmlDataTable.isCurrentDetailExpanded()) {
+    
+                    boolean embedded = false;
+                    if (detailStampFacet != null) {
+                        embedded = isEmbeddedTable(detailStampFacet);
+                    }
+    
+                    ResponseWriter writer = facesContext.getResponseWriter();
+    
+                    if (!embedded) {
+                        writer.startElement(HTML.TR_ELEM, uiData);
+                        writer.startElement(HTML.TD_ELEM, uiData);
+                        //TOMAHAWK-1087 datatable dont renders a detail correct 
+                        //if a UIColumns is used we have to count UIColumns 
+                        //elements as component.getRowCount()
+                        //instead of just get the number of children available,
+                        //so the colspan could be assigned correctly.
+                        int childCount = 0;
+                        for (Iterator childIter = uiData.getChildren().iterator();
+                            childIter.hasNext();)
                         {
-                            childCount++;
+                            UIComponent childComp = (UIComponent) childIter.next();
+                            if (childComp instanceof UIColumns)
+                            {
+                                UIColumns v = (UIColumns) childComp;
+                                childCount += v.getRowCount();
+                            }
+                            else
+                            {
+                                childCount++;
+                            }
                         }
+                        writer.writeAttribute(HTML.COLSPAN_ATTR, new Integer(
+                                childCount), null);
+                    }
+    
+                    if (detailStampFacet != null) {
+                        RendererUtils.renderChild(facesContext, detailStampFacet);
+                    }
+    
+                    if (!embedded) {
+                        writer.endElement(HTML.TD_ELEM);
+                        writer.endElement(HTML.TR_ELEM);
                     }
-                    writer.writeAttribute(HTML.COLSPAN_ATTR, new Integer(
-                            childCount), null);
-                }
-
-                if (detailStampFacet != null) {
-                    RendererUtils.renderChild(facesContext, detailStampFacet);
-                }
-
-                if (!embedded) {
-                    writer.endElement(HTML.TD_ELEM);
-                    writer.endElement(HTML.TR_ELEM);
                 }
             }
         }



Mime
View raw message