You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2005/05/25 16:53:46 UTC
svn commit: r178447 -
/myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlGridRendererBase.java
Author: mmarinschek
Date: Wed May 25 07:53:43 2005
New Revision: 178447
URL: http://svn.apache.org/viewcvs?rev=178447&view=rev
Log:
Thanks to Mathias Broekelmann for his suggestion
Modified:
myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlGridRendererBase.java
Modified: myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlGridRendererBase.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlGridRendererBase.java?rev=178447&r1=178446&r2=178447&view=diff
==============================================================================
--- myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlGridRendererBase.java (original)
+++ myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlGridRendererBase.java Wed May 25 07:53:43 2005
@@ -139,111 +139,99 @@
int columns)
throws IOException
{
- try
- {
- writer.startElement(HTML.TBODY_ELEM, component);
+ writer.startElement(HTML.TBODY_ELEM, component);
- String columnClasses;
- String rowClasses;
- if (component instanceof HtmlPanelGrid)
- {
- columnClasses = ((HtmlPanelGrid)component).getColumnClasses();
- rowClasses = ((HtmlPanelGrid)component).getRowClasses();
- }
- else
- {
- columnClasses = (String)component.getAttributes().get(JSFAttr.COLUMN_CLASSES_ATTR);
- rowClasses = (String)component.getAttributes().get(JSFAttr.ROW_CLASSES_ATTR);
- }
+ String columnClasses;
+ String rowClasses;
+ if (component instanceof HtmlPanelGrid)
+ {
+ columnClasses = ((HtmlPanelGrid)component).getColumnClasses();
+ rowClasses = ((HtmlPanelGrid)component).getRowClasses();
+ }
+ else
+ {
+ columnClasses = (String)component.getAttributes().get(JSFAttr.COLUMN_CLASSES_ATTR);
+ rowClasses = (String)component.getAttributes().get(JSFAttr.ROW_CLASSES_ATTR);
+ }
- String[] columnClassesArray = (columnClasses == null)
- ? ArrayUtils.EMPTY_STRING_ARRAY
- : StringUtils.trim(StringUtils.splitShortString(columnClasses, ','));
- int columnClassesCount = columnClassesArray.length;
-
- String[] rowClassesArray = (rowClasses == null)
- ? ArrayUtils.EMPTY_STRING_ARRAY
- : StringUtils.trim(StringUtils.splitShortString(rowClasses, ','));
- int rowClassesCount = rowClassesArray.length;
+ String[] columnClassesArray = (columnClasses == null)
+ ? ArrayUtils.EMPTY_STRING_ARRAY
+ : StringUtils.trim(StringUtils.splitShortString(columnClasses, ','));
+ int columnClassesCount = columnClassesArray.length;
+
+ String[] rowClassesArray = (rowClasses == null)
+ ? ArrayUtils.EMPTY_STRING_ARRAY
+ : StringUtils.trim(StringUtils.splitShortString(rowClasses, ','));
+ int rowClassesCount = rowClassesArray.length;
- int childCount = component.getChildCount();
- if (childCount > 0)
+ int childCount = component.getChildCount();
+ if (childCount > 0)
+ {
+ int columnIndex = 0;
+ int rowClassIndex = 0;
+ boolean rowStarted = false;
+ for (Iterator it = component.getChildren().iterator(); it.hasNext(); )
{
- int columnIndex = 0;
- int rowClassIndex = 0;
- boolean rowStarted = false;
- for (Iterator it = component.getChildren().iterator(); it.hasNext(); )
+ UIComponent child = (UIComponent)it.next();
+ if (child.isRendered())
{
- UIComponent child = (UIComponent)it.next();
- if (child.isRendered())
+ if (columnIndex == 0)
{
- if (columnIndex == 0)
+ //start of new/next row
+ if (rowStarted)
{
- //start of new/next row
- if (rowStarted)
- {
- //do we have to close the last row?
- writer.endElement(HTML.TR_ELEM);
- HtmlRendererUtils.writePrettyLineSeparator(context);
- }
- writer.startElement(HTML.TR_ELEM, component);
- if (rowClassIndex < rowClassesCount) {
- writer.writeAttribute(HTML.CLASS_ATTR, rowClassesArray[rowClassIndex], null);
- }
- rowStarted = true;
- rowClassIndex++;
- if (rowClassIndex == rowClassesCount) {
- rowClassIndex = 0;
- }
+ //do we have to close the last row?
+ writer.endElement(HTML.TR_ELEM);
+ HtmlRendererUtils.writePrettyLineSeparator(context);
}
-
- writer.startElement(HTML.TD_ELEM, component);
- if (columnIndex < columnClassesCount)
- {
- writer.writeAttribute(HTML.CLASS_ATTR, columnClassesArray[columnIndex], null);
+ writer.startElement(HTML.TR_ELEM, component);
+ if (rowClassIndex < rowClassesCount) {
+ writer.writeAttribute(HTML.CLASS_ATTR, rowClassesArray[rowClassIndex], null);
}
- RendererUtils.renderChild(context, child);
- writer.endElement(HTML.TD_ELEM);
-
- columnIndex++;
- if (columnIndex >= columns) {
- columnIndex = 0;
+ rowStarted = true;
+ rowClassIndex++;
+ if (rowClassIndex == rowClassesCount) {
+ rowClassIndex = 0;
}
}
+
+ writer.startElement(HTML.TD_ELEM, component);
+ if (columnIndex < columnClassesCount)
+ {
+ writer.writeAttribute(HTML.CLASS_ATTR, columnClassesArray[columnIndex], null);
+ }
+ RendererUtils.renderChild(context, child);
+ writer.endElement(HTML.TD_ELEM);
+
+ columnIndex++;
+ if (columnIndex >= columns) {
+ columnIndex = 0;
+ }
}
+ }
- if (rowStarted)
+ if (rowStarted)
+ {
+ if (columnIndex > 0)
{
- if (columnIndex > 0)
+ if (log.isWarnEnabled()) log.warn("PanelGrid " + component.getClientId(context) + " has not enough children. Child count should be a multiple of the columns attribute.");
+ //Render empty columns, so that table is correct
+ for ( ; columnIndex < columns; columnIndex++)
{
- if (log.isWarnEnabled()) log.warn("PanelGrid " + component.getClientId(context) + " has not enough children. Child count should be a multiple of the columns attribute.");
- //Render empty columns, so that table is correct
- for ( ; columnIndex < columns; columnIndex++)
+ writer.startElement(HTML.TD_ELEM, component);
+ if (columnIndex < columnClassesCount)
{
- writer.startElement(HTML.TD_ELEM, component);
- if (columnIndex < columnClassesCount)
- {
- writer.writeAttribute(HTML.CLASS_ATTR, columnClassesArray[columnIndex], null);
- }
- writer.endElement(HTML.TD_ELEM);
+ writer.writeAttribute(HTML.CLASS_ATTR, columnClassesArray[columnIndex], null);
}
+ writer.endElement(HTML.TD_ELEM);
}
- writer.endElement(HTML.TR_ELEM);
- HtmlRendererUtils.writePrettyLineSeparator(context);
}
+ writer.endElement(HTML.TR_ELEM);
+ HtmlRendererUtils.writePrettyLineSeparator(context);
}
-
- writer.endElement(HTML.TBODY_ELEM);
- }
- catch(IOException ex)
- {
- throw ex;
- }
- catch(RuntimeException ex2)
- {
- log.error("Exception while rendering children of panel-grid.",ex2);
- throw ex2;
}
+
+ writer.endElement(HTML.TBODY_ELEM);
}
}