You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lf...@apache.org on 2006/08/21 23:53:20 UTC
svn commit: r433375 - in /myfaces:
shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/
tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/
tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/
tomaha...
Author: lfrohman
Date: Mon Aug 21 14:53:18 2006
New Revision: 433375
URL: http://svn.apache.org/viewvc?rev=433375&view=rev
Log:
Fix for TOMAHAWK-441 -- Add orientation parameter to NewspaperTable.
Modified:
myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/NewspaperTable.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java
myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_newspaper_table_attributes.xml
myfaces/tomahawk/trunk/core/src/site/xdoc/extDataTable.xml
myfaces/tomahawk/trunk/examples/simple/src/main/webapp/newspaperTable.jsp
Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java?rev=433375&r1=433374&r2=433375&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java Mon Aug 21 14:53:18 2006
@@ -74,7 +74,15 @@
protected boolean hasNewspaperTableSpacer(UIComponent component) {
return false;
}
-
+
+ /**
+ * @param component dataTable
+ * @return whether dataTable has newspaper columns layed out horizontally
+ */
+ protected boolean isNewspaperHorizontalOrientation(UIComponent component) {
+ return false;
+ }
+
/**
* @see javax.faces.render.Renderer#getRendersChildren()
*/
@@ -222,44 +230,38 @@
if((last - first) % newspaperColumns == 0)
newspaperRows = (last - first) / newspaperColumns;
else newspaperRows = ((last - first) / newspaperColumns) + 1;
+ boolean newspaperHorizontalOrientation = isNewspaperHorizontalOrientation(component);
// walk through the newspaper rows
for(int nr = 0; nr < newspaperRows; nr++)
{
- // single column newspaper row assignment done here
- int currentRow = nr + first;
- // if this row is not to be rendered
- if (currentRow >= last) continue;
+ // walk through the newspaper columns
+ for(int nc = 0; nc < newspaperColumns; nc++) {
- uiData.setRowIndex(currentRow);
- if (!uiData.isRowAvailable()) {
+ // the current row in the 'real' table
+ int currentRow;
+ if (newspaperHorizontalOrientation)
+ currentRow = nr * newspaperColumns + nc + first;
+ else
+ currentRow = nc * newspaperRows + nr + first;
+
+ // if this row is not to be rendered
+ if(currentRow >= last) continue;
+
+ // bail if any row does not exist
+ uiData.setRowIndex(currentRow);
+ if(!uiData.isRowAvailable()) {
log.error("Row is not available. Rowindex = " + currentRow);
break;
- }
+ }
- beforeRow(facesContext, uiData);
+ if (nc == 0) {
+ // first column in table, start new row
+ beforeRow(facesContext, uiData);
- HtmlRendererUtils.writePrettyLineSeparator(facesContext);
- renderRowStart(facesContext, writer, uiData, styles, nr);
-
- // walk through the newspaper columns
- for(int nc = 0; nc < newspaperColumns; nc++) {
-
- // additional newspaper column row assignment handled here
- if (nc > 0) {
- // the current row in the 'real' table
- currentRow = nc * newspaperRows + nr + first;
-
- // if this row is not to be rendered
- if(currentRow >= last) continue;
-
- // bail if any row does not exist
- uiData.setRowIndex(currentRow);
- if(!uiData.isRowAvailable()) {
- log.error("Row is not available. Rowindex = " + currentRow);
- break;
- }
+ HtmlRendererUtils.writePrettyLineSeparator(facesContext);
+ renderRowStart(facesContext, writer, uiData, styles, nr);
}
List children = getChildren(component);
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/NewspaperTable.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/NewspaperTable.java?rev=433375&r1=433374&r2=433375&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/NewspaperTable.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/NewspaperTable.java Mon Aug 21 14:53:18 2006
@@ -25,7 +25,9 @@
*/
public interface NewspaperTable {
+ public static final String NEWSPAPER_HORIZONTAL_ORIENTATION = "horizontal";
public int getNewspaperColumns();
public UIComponent getSpacer();
+ public String getNewspaperOrientation();
}
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java?rev=433375&r1=433374&r2=433375&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java Mon Aug 21 14:53:18 2006
@@ -57,9 +57,12 @@
/** the property names */
public static final String NEWSPAPER_COLUMNS_PROPERTY = "newspaperColumns";
public static final String SPACER_FACET_NAME = "spacer";
+ public static final String NEWSPAPER_ORIENTATION_PROPERTY = "newspaperOrientation";
/** the value of the column count property */
private int _newspaperColumns = 1;
+ /** the value of the newspaper orientation property */
+ private String _newspaperOrientation = null;
private _SerializableDataModel _preservedDataModel;
@@ -689,7 +692,7 @@
{
boolean preserveSort = isPreserveSort();
- Object values[] = new Object[33];
+ Object values[] = new Object[34];
values[0] = super.saveState(context);
values[1] = _preserveDataModel;
@@ -736,6 +739,7 @@
values[31] = new Integer(_sortColumnIndex);
values[32] = new Integer(_newspaperColumns);
+ values[33] = _newspaperOrientation;
return values;
}
@@ -864,6 +868,7 @@
_sortedColumnVar = (String)values[30];
_sortColumnIndex = values[31] != null ? ((Integer)values[31]).intValue() : -1;
_newspaperColumns = ((Integer)values[32]).intValue();
+ _newspaperOrientation = (String) values[33];
}
public _SerializableDataModel getSerializableDataModel()
@@ -1294,6 +1299,19 @@
}
public void setNewspaperColumns(int newspaperColumns) {
this._newspaperColumns = newspaperColumns;
+ }
+
+ /**
+ * Set the orientation of the newspaper columns.
+ */
+ public void setNewspaperOrientation(String newspaperOrientation)
+ {
+ this._newspaperOrientation = newspaperOrientation;
+ }
+
+ public String getNewspaperOrientation()
+ {
+ return _newspaperOrientation;
}
/**
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java?rev=433375&r1=433374&r2=433375&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java Mon Aug 21 14:53:18 2006
@@ -98,6 +98,21 @@
return super.hasNewspaperTableSpacer(component);
}
+ /**
+ * @param component dataTable
+ * @return if the orientation of the has newspaper columns is horizontal
+ */
+ protected boolean isNewspaperHorizontalOrientation(UIComponent component) {
+ if (component instanceof NewspaperTable)
+ {
+ // get the value of the newspaperOrientation attribute, any value besides horizontal
+ // means vertical, the default
+ NewspaperTable newspaperTable = (NewspaperTable)component;
+ return NewspaperTable.NEWSPAPER_HORIZONTAL_ORIENTATION.equals(newspaperTable.getNewspaperOrientation());
+ }
+ return super.isNewspaperHorizontalOrientation(component);
+ }
+
protected void afterRow(FacesContext facesContext, UIData uiData) throws IOException {
super.afterRow(facesContext, uiData);
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java?rev=433375&r1=433374&r2=433375&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java Mon Aug 21 14:53:18 2006
@@ -76,6 +76,8 @@
/** the number of newspaper columns */
private String _newspaperColumns = null;
+ /** the orientation of the newspaper table - horizontal/vertical */
+ private String _newspaperOrientation = null;
public void release()
{
@@ -114,6 +116,7 @@
_rowGroupStyleClass = null;
_newspaperColumns = null;
+ _newspaperOrientation = null;
}
protected void setProperties(UIComponent component)
@@ -152,7 +155,8 @@
setStringProperty(component, "rowGroupStyle", _rowGroupStyle);
setStringProperty(component, "rowGroupStyleClass", _rowGroupStyleClass);
- setIntegerProperty(component, HtmlNewspaperTable.NEWSPAPER_COLUMNS_PROPERTY, _newspaperColumns);
+ setIntegerProperty(component, HtmlDataTable.NEWSPAPER_COLUMNS_PROPERTY, _newspaperColumns);
+ setStringProperty(component, HtmlDataTable.NEWSPAPER_ORIENTATION_PROPERTY, _newspaperOrientation);
}
public void setPreserveDataModel(String preserveDataModel)
@@ -310,6 +314,10 @@
public void setNewspaperColumns(String newspaperColumns) {
this._newspaperColumns = newspaperColumns;
+ }
+
+ public void setNewspaperOrientation(String newspaperOrientation) {
+ this._newspaperOrientation = newspaperOrientation;
}
}
Modified: myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_newspaper_table_attributes.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_newspaper_table_attributes.xml?rev=433375&r1=433374&r2=433375&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_newspaper_table_attributes.xml (original)
+++ myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_newspaper_table_attributes.xml Mon Aug 21 14:53:18 2006
@@ -7,3 +7,14 @@
Default: 1
</description>
</attribute>
+ <attribute>
+ <name>newspaperOrientation</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ The orientation of the newspaper columns in the
+ newspaper table - "horizontal" or "vertical".
+ Default: vertical
+ </description>
+ </attribute>
+
Modified: myfaces/tomahawk/trunk/core/src/site/xdoc/extDataTable.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/site/xdoc/extDataTable.xml?rev=433375&r1=433374&r2=433375&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/site/xdoc/extDataTable.xml (original)
+++ myfaces/tomahawk/trunk/core/src/site/xdoc/extDataTable.xml Mon Aug 21 14:53:18 2006
@@ -88,6 +88,7 @@
[ previousRowDataVar="variable name" ]
[ rowId="value-binding" ]
[ newspaperColumns="value-binding" ]
+ [ newspaperOrientation="value-binding" ]
[ rowStyleClass="css styleclass" ]
[ rowStyle="inline css style" ]
[ rowOnClick="javascript" ]
@@ -131,7 +132,9 @@
parameters.<br /> <code>rowId="value-binding"</code> - The id to use for
<tr> elements that are generated by the table. <br />
<code>newspaperColumns="value-binding"</code> - The number of layout
- columns to wrap the table through.<br /> <code>rowStyleClass="css style
+ columns to wrap the table through.<br />
+ <code>newspaperOrientation="value-binding"</code> - The orientation of
+ the columns in the table.<br /> <code>rowStyleClass="css style
class"</code> - the style class to use for <tr> elements that are
generated by the table. Can be a value-binding to assign row-data
specific style classes<br /> <code>rowStyle="inline css style"</code> -
@@ -198,10 +201,12 @@
narrow table to be wrapped so that it becomes a short, wide table. This
allows more information to be shown on a single screen. This is commonly
used to present checkboxes for a long list of items. Use the "spacer"
- facet to specify a component displayed between layout columns. <br />
+ facet to specify a component displayed between layout columns. The
+ newspaperOrientation attribute specifies if the columns will be layed out
+ in a vertical or horizontal manner,<br />
Example:<br />
<source xml:space="preserve"><![CDATA[
-<t:dataTable newspaperColumns="3" value="#{addressBB.states}" var="state">
+<t:dataTable newspaperColumns="3" value="#{addressBB.states}" newspaperOrientation="horizontal" var="state">
<f:facet name="spacer">
<f:verbatim>&#160;</f:verbatim>
</f:facet>
Modified: myfaces/tomahawk/trunk/examples/simple/src/main/webapp/newspaperTable.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/examples/simple/src/main/webapp/newspaperTable.jsp?rev=433375&r1=433374&r2=433375&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/webapp/newspaperTable.jsp (original)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/webapp/newspaperTable.jsp Mon Aug 21 14:53:18 2006
@@ -45,7 +45,7 @@
headerClass="standardTable_Header"
footerClass="standardTable_Header"
rowClasses="standardTable_Row1,standardTable_Row2"
- columnClasses="standardTable_Column,standardTable_ColumnCentered,standardTable_Column"
+ columnClasses="standardTable_Column,standardTable_ColumnCentered"
var="country"
value="#{countryList.countries}">
<f:facet name="spacer">
@@ -75,7 +75,38 @@
headerClass="standardTable_Header"
footerClass="standardTable_Header"
rowClasses="standardTable_Row1,standardTable_Row2"
- columnClasses="standardTable_Column,standardTable_ColumnCentered,standardTable_Column"
+ columnClasses="standardTable_Column,standardTable_ColumnCentered"
+ var="country"
+ value="#{countryList.countries}">
+ <f:facet name="spacer">
+ <f:verbatim> </f:verbatim>
+ </f:facet>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="#{example_messages['label_country_name']}" />
+ </f:facet>
+ <h:outputText value="#{country.name}" />
+ </h:column>
+
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="#{example_messages['label_country_iso']}" />
+ </f:facet>
+ <h:outputText value="#{country.isoCode}" />
+ </h:column>
+
+ </t:dataTable>
+
+ <h:outputText value="Implementation using t:dataTable horizontally" />
+
+ <t:dataTable id="dataNew2"
+ newspaperColumns="2"
+ newspaperOrientation="horizontal"
+ styleClass="standardTable"
+ headerClass="standardTable_Header"
+ footerClass="standardTable_Header"
+ rowClasses="standardTable_Row1,standardTable_Row2"
+ columnClasses="standardTable_Column,standardTable_ColumnCentered"
var="country"
value="#{countryList.countries}">
<f:facet name="spacer">