You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Mathias Broekelmann (JIRA)" <my...@incubator.apache.org> on 2005/04/07 12:07:42 UTC
[jira] Commented: (MYFACES-171) Wrong src tree for UIColumns
[ http://issues.apache.org/jira/browse/MYFACES-171?page=comments#action_62344 ]
Mathias Broekelmann commented on MYFACES-171:
---------------------------------------------
UIColumns is used by HtmlTableRendererBase which is also in share. If it is ok to use a class from components in share I´ve no problem with it.
If not I would modify HtmlTableRendererBase to create some protected methods which will be implemented by the HtmlTableRenderer in components to avoid copying the code.
Here is a patch which moves the UIColumns component:
Index: conf/faces-config.xml
===================================================================
RCS file: /home/cvspublic/incubator-myfaces/conf/faces-config.xml,v
retrieving revision 1.116
diff -u -r1.116 faces-config.xml
--- conf/faces-config.xml 29 Mar 2005 11:40:50 -0000 1.116
+++ conf/faces-config.xml 7 Apr 2005 10:00:23 -0000
@@ -283,7 +283,7 @@
<component>
<component-type>org.apache.myfaces.Columns</component-type>
- <component-class>org.apache.myfaces.component.UIColumns</component-class>
+ <component-class>org.apache.myfaces.custom.crosstable.UIColumns</component-class>
</component>
<!-- additional "by type" converters -->
Index: src/components/org/apache/myfaces/component/html/ext/HtmlDataTable.java
===================================================================
RCS file: /home/cvspublic/incubator-myfaces/src/components/org/apache/myfaces/component/html/ext/HtmlDataTable.java,v
retrieving revision 1.20
diff -u -r1.20 HtmlDataTable.java
--- src/components/org/apache/myfaces/component/html/ext/HtmlDataTable.java 29 Mar 2005 11:40:50 -0000 1.20
+++ src/components/org/apache/myfaces/component/html/ext/HtmlDataTable.java 7 Apr 2005 10:00:24 -0000
@@ -17,7 +17,7 @@
import org.apache.myfaces.component.UserRoleAware;
import org.apache.myfaces.component.UserRoleUtils;
-import org.apache.myfaces.component.UIColumns;
+import org.apache.myfaces.custom.crosstable.UIColumns;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Index: src/components/org/apache/myfaces/custom/crosstable/HtmlColumnsTag.java
===================================================================
RCS file: /home/cvspublic/incubator-myfaces/src/components/org/apache/myfaces/custom/crosstable/HtmlColumnsTag.java,v
retrieving revision 1.1
diff -u -r1.1 HtmlColumnsTag.java
--- src/components/org/apache/myfaces/custom/crosstable/HtmlColumnsTag.java 29 Mar 2005 11:40:50 -0000 1.1
+++ src/components/org/apache/myfaces/custom/crosstable/HtmlColumnsTag.java 7 Apr 2005 10:00:24 -0000
@@ -17,7 +17,6 @@
import javax.faces.component.UIComponent;
-import org.apache.myfaces.component.UIColumns;
import org.apache.myfaces.renderkit.JSFAttr;
import org.apache.myfaces.taglib.html.HtmlComponentBodyTagBase;
Index: src/components/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
===================================================================
RCS file: /home/cvspublic/incubator-myfaces/src/components/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java,v
retrieving revision 1.2
diff -u -r1.2 HtmlTableRenderer.java
--- src/components/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java 13 Oct 2004 11:50:59 -0000 1.2
+++ src/components/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java 7 Apr 2005 10:00:24 -0000
@@ -5,10 +5,86 @@
* @version $Revision: 1.2 $ $Date: 2004/10/13 11:50:59 $
*/
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.apache.myfaces.custom.crosstable.UIColumns;
import org.apache.myfaces.renderkit.html.HtmlTableRendererBase;
public class HtmlTableRenderer
extends HtmlTableRendererBase
{
//private static final Log log = LogFactory.getLog(HtmlTableRenderer.class);
+
+ protected void encodeColumnChild(FacesContext facesContext, ResponseWriter writer,
+ UIData uiData, UIComponent component, String columnStyle) throws IOException
+ {
+ super.encodeColumnChild(facesContext, writer, uiData, component, columnStyle);
+ if (component instanceof UIColumns)
+ {
+ UIColumns columns = (UIColumns) component;
+ for (int k = 0, colSize = columns.getRowCount(); k < colSize; k++)
+ {
+ columns.setRowIndex(k);
+ renderColumnBody(facesContext, writer, uiData, component, columnStyle);
+ }
+ columns.setRowIndex(-1);
+ }
+ }
+
+ protected void renderColumnChildHeaderOrFooterRow(FacesContext facesContext,
+ ResponseWriter writer, UIComponent uiComponent, String styleClass, boolean header) throws IOException
+ {
+ super.renderColumnChildHeaderOrFooterRow(facesContext, writer, uiComponent, styleClass, header);
+ if (uiComponent instanceof UIColumns)
+ {
+ UIColumns columns = (UIColumns) uiComponent;
+ for (int i = 0, size = columns.getRowCount(); i < size; i++)
+ {
+ columns.setRowIndex(i);
+ if (header)
+ {
+ renderColumnHeaderCell(facesContext, writer, columns, columns.getHeader(),
+ styleClass, 0);
+ }
+ else
+ {
+ renderColumnFooterCell(facesContext, writer, columns, columns.getFooter(),
+ styleClass, 0);
+ }
+ }
+ columns.setRowIndex(-1);
+ }
+ }
+
+ /**
+ * @see org.apache.myfaces.renderkit.html.HtmlTableRendererBase#determineChildColSpan(javax.faces.component.UIComponent)
+ */
+ protected int determineChildColSpan(UIComponent uiComponent)
+ {
+ int result = super.determineChildColSpan(uiComponent);
+ if (uiComponent instanceof UIColumns)
+ {
+ result += ((UIColumns) uiComponent).getRowCount();
+ }
+ return result;
+ }
+
+ /**
+ * @see org.apache.myfaces.renderkit.html.HtmlTableRendererBase#hasFacet(boolean, javax.faces.component.UIComponent)
+ */
+ protected boolean hasFacet(boolean header, UIComponent uiComponent)
+ {
+ boolean result = super.hasFacet(header, uiComponent);
+ if (!result && uiComponent instanceof UIColumns)
+ {
+ UIColumns columns = (UIColumns) uiComponent;
+ result = header ? columns.getHeader() != null : columns.getFooter() != null;
+ }
+ return result;
+ }
}
Index: src/share/org/apache/myfaces/component/UIColumns.java
===================================================================
RCS file: src/share/org/apache/myfaces/component/UIColumns.java
diff -N src/share/org/apache/myfaces/component/UIColumns.java
--- src/share/org/apache/myfaces/component/UIColumns.java 29 Mar 2005 11:40:50 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,56 +0,0 @@
-/*
- * Copyright 2004 The Apache Software Foundation.
- *
- * Licensed 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;
-
-import javax.faces.component.UIData;
-
-/**
- * @author Mathias Broekelmann (latest modification by $Author: matzew $)
- * @version $Revision: 1.1 $ $Date: 2005/03/29 11:40:50 $
- * $Log: UIColumns.java,v $
- * Revision 1.1 2005/03/29 11:40:50 matzew
- * added new crosstable component (x:columns). Contributed by Mathias Broekelmann
- *
- */
-public class UIColumns extends UIData
-{
- public static final String COMPONENT_TYPE = "org.apache.myfaces.Columns";
- public static final String COMPONENT_FAMILY = UIData.COMPONENT_FAMILY;
-
- /**
- *
- */
- public UIColumns()
- {
- super();
- }
-
- /**
- * @see javax.faces.component.UIComponentBase#getRendererType()
- */
- public String getRendererType()
- {
- return null;
- }
-
- /**
- * @see javax.faces.component.UIComponent#getFamily()
- */
- public String getFamily()
- {
- return COMPONENT_FAMILY;
- }
-}
Index: src/share/org/apache/myfaces/renderkit/html/HtmlTableRendererBase.java
===================================================================
RCS file: /home/cvspublic/incubator-myfaces/src/share/org/apache/myfaces/renderkit/html/HtmlTableRendererBase.java,v
retrieving revision 1.9
diff -u -r1.9 HtmlTableRendererBase.java
--- src/share/org/apache/myfaces/renderkit/html/HtmlTableRendererBase.java 29 Mar 2005 11:40:50 -0000 1.9
+++ src/share/org/apache/myfaces/renderkit/html/HtmlTableRendererBase.java 7 Apr 2005 10:00:24 -0000
@@ -19,7 +19,6 @@
import org.apache.myfaces.renderkit.RendererUtils;
import org.apache.myfaces.util.ArrayUtils;
import org.apache.myfaces.util.StringUtils;
-import org.apache.myfaces.component.UIColumns;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -151,26 +150,11 @@
List children = component.getChildren();
for (int j = 0, size = component.getChildCount(); j < size; j++)
{
- UIComponent child = (UIComponent) children.get(j);
- if(child.isRendered())
- {
- if (child instanceof UIColumn)
- {
- String columnStyle = styles.getColumnStyle(j);
- renderColumnBody(facesContext, writer, uiData, child, columnStyle);
- }
- else if (child instanceof UIColumns)
- {
- UIColumns columns = (UIColumns) child;
- for (int k = 0, colSize = columns.getRowCount(); k < colSize; k++)
- {
- columns.setRowIndex(k);
- String columnStyle = styles.getColumnStyle(j);
- renderColumnBody(facesContext, writer, uiData, child, columnStyle);
- }
- columns.setRowIndex(-1);
- }
- }
+ UIComponent child = (UIComponent) children.get(j);
+ if(child.isRendered())
+ {
+ encodeColumnChild(facesContext, writer, uiData, child, styles.getColumnStyle(j));
+ }
}
renderRowEnd(facesContext, writer, uiData);
@@ -179,6 +163,15 @@
writer.endElement(HTML.TBODY_ELEM);
}
+ protected void encodeColumnChild(FacesContext facesContext, ResponseWriter writer,
+ UIData uiData, UIComponent component, String columnStyle) throws IOException
+ {
+ if (component instanceof UIColumn)
+ {
+ renderColumnBody(facesContext, writer, uiData, component, columnStyle);
+ }
+ }
+
/**
* Renders the body of a given <code>UIColumn</code> (everything but the header and footer facets).
* @param facesContext the <code>FacesContext</code>.
@@ -311,24 +304,11 @@
UIComponent uiComponent = (UIComponent) it.next();
if(uiComponent.isRendered())
{
- if (uiComponent instanceof UIColumn)
- {
- colspan++;
- if (!hasColumnFacet)
- {
- hasColumnFacet = header ? ((UIColumn) uiComponent).getHeader() != null : ((UIColumn) uiComponent)
- .getFooter() != null;
- }
- }
- else if (uiComponent instanceof UIColumns)
- {
- UIColumns columns = (UIColumns) uiComponent;
- colspan += columns.getRowCount();
- if (!hasColumnFacet)
- {
- hasColumnFacet = header ? columns.getHeader() != null : columns.getFooter() != null;
- }
- }
+ colspan += determineChildColSpan(uiComponent);
+ if(!hasColumnFacet)
+ {
+ hasColumnFacet = hasFacet(header, uiComponent);
+ }
}
}
@@ -362,6 +342,30 @@
}
/**
+ * @param header
+ * @param uiComponent
+ * @return
+ */
+ protected boolean hasFacet(boolean header, UIComponent uiComponent)
+ {
+ if (uiComponent instanceof UIColumn)
+ {
+ UIColumn uiColumn = (UIColumn) uiComponent;
+ return header ? uiColumn.getHeader() != null : uiColumn.getFooter() != null;
+ }
+ return false;
+ }
+
+ protected int determineChildColSpan(UIComponent uiComponent)
+ {
+ if (uiComponent instanceof UIColumn)
+ {
+ return 1;
+ }
+ return 0;
+ }
+
+ /**
* Renders the header row of the table being rendered.
* @param facesContext the <code>FacesContext</code>.
* @param writer the <code>ResponseWriter</code>.
@@ -461,43 +465,30 @@
UIComponent uiComponent = (UIComponent) it.next();
if(uiComponent.isRendered())
{
- if (uiComponent instanceof UIColumn)
- {
- if (header)
- {
- renderColumnHeaderCell(facesContext, writer, uiComponent,
- ((UIColumn) uiComponent).getHeader(), styleClass, 0);
- }
- else
- {
- renderColumnFooterCell(facesContext, writer, uiComponent,
- ((UIColumn) uiComponent).getFooter(), styleClass, 0);
- }
- }
- else if (uiComponent instanceof UIColumns)
- {
- UIColumns columns = (UIColumns) uiComponent;
- for (int i = 0, size = columns.getRowCount(); i < size; i++)
- {
- columns.setRowIndex(i);
- if (header)
- {
- renderColumnHeaderCell(facesContext, writer, columns, columns.getHeader(),
- styleClass, 0);
- }
- else
- {
- renderColumnFooterCell(facesContext, writer, columns, columns.getFooter(),
- styleClass, 0);
- }
- }
- columns.setRowIndex(-1);
- }
+ renderColumnChildHeaderOrFooterRow(facesContext, writer, uiComponent, styleClass, header);
}
}
writer.endElement(HTML.TR_ELEM);
}
+ protected void renderColumnChildHeaderOrFooterRow(FacesContext facesContext,
+ ResponseWriter writer, UIComponent uiComponent, String styleClass, boolean header) throws IOException
+ {
+ if (uiComponent instanceof UIColumn)
+ {
+ if (header)
+ {
+ renderColumnHeaderCell(facesContext, writer, uiComponent,
+ ((UIColumn) uiComponent).getHeader(), styleClass, 0);
+ }
+ else
+ {
+ renderColumnFooterCell(facesContext, writer, uiComponent,
+ ((UIColumn) uiComponent).getFooter(), styleClass, 0);
+ }
+ }
+ }
+
/**
* Renders the header facet for the given <code>UIColumn</code>.
* @param facesContext the <code>FacesContext</code>.
> Wrong src tree for UIColumns
> ----------------------------
>
> Key: MYFACES-171
> URL: http://issues.apache.org/jira/browse/MYFACES-171
> Project: MyFaces
> Type: Task
> Versions: 1.0.9 beta
> Reporter: Manfred Geiler
> Priority: Minor
>
> UIColumns class for new crosstable component should be moved from share src tree to components tree.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira