You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by mi...@apache.org on 2003/09/06 16:04:43 UTC
cvs commit: jakarta-tapestry/contrib/src/org/apache/tapestry/contrib Contrib.library
mindbridge 2003/09/06 07:04:43
Modified: contrib/src/org/apache/tapestry/contrib/table/model/simple
SimpleTableColumn.java
contrib/src/org/apache/tapestry/contrib/table/components/inserted
SimpleTableColumnPage.page
SimpleTableColumnPage.html
SimpleTableColumnComponent.java
framework/src/org/apache/tapestry TapestryStrings.properties
contrib/src/org/apache/tapestry/contrib Contrib.library
Added: contrib/src/org/apache/tapestry/contrib/table/model/simple
SimpleTableColumnFormRendererSource.java
contrib/src/org/apache/tapestry/contrib/table/components/inserted
SimpleTableColumnFormComponent.html
SimpleTableColumnFormComponent.jwc
SimpleTableColumnFormComponent.java
contrib/src/org/apache/tapestry/contrib/table/components
TableFormRows.java TableFormPages.html
TableFormPages.jwc TableFormPages.java
TableFormRows.html TableFormRows.jwc
contrib/src/org/apache/tapestry/contrib/form
FormConditional.java FormConditional.jwc
Log:
FormConditional component and form-related Table components
Revision Changes Path
1.3 +2 -2 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/model/simple/SimpleTableColumn.java
Index: SimpleTableColumn.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/model/simple/SimpleTableColumn.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SimpleTableColumn.java 31 Aug 2003 19:14:30 -0000 1.2
+++ SimpleTableColumn.java 6 Sep 2003 14:04:42 -0000 1.3
@@ -222,7 +222,7 @@
return 0;
// non-comparable values (null included) are considered smaller
- // than the comparable one
+ // than the comparable ones
if (!bComparable1)
return -1;
1.1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/model/simple/SimpleTableColumnFormRendererSource.java
Index: SimpleTableColumnFormRendererSource.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation", "Tapestry"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* or "Tapestry", nor may "Apache" or "Tapestry" appear in their
* name, without prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE TAPESTRY CONTRIBUTOR COMMUNITY
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.tapestry.contrib.table.model.simple;
import org.apache.tapestry.IRender;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.util.ComponentAddress;
import org.apache.tapestry.contrib.table.model.ITableColumn;
import org.apache.tapestry.contrib.table.model.ITableModelSource;
import org.apache.tapestry.contrib.table.model.ITableRendererSource;
import org.apache.tapestry.contrib.table.model.common.ComponentTableRendererSource;
/**
* This is a simple implementation of
* {@link org.apache.tapestry.contrib.table.model.ITableRendererSource}
* that returns a standard renderer of a column header. <p>
*
* This implementation requires that the column passed is of type SimpleTableColumn
*
* @see org.apache.tapestry.contrib.table.model.common.AbstractTableColumn
* @version $Id: SimpleTableColumnFormRendererSource.java,v 1.1 2003/09/06 14:04:42 mindbridge Exp $
* @author mindbridge
* @since 2.3
*/
public class SimpleTableColumnFormRendererSource implements ITableRendererSource
{
private ComponentTableRendererSource m_objComponentRenderer;
public SimpleTableColumnFormRendererSource()
{
m_objComponentRenderer = null;
}
/**
* @see org.apache.tapestry.contrib.table.model.ITableRendererSource#getRenderer(IRequestCycle, ITableModelSource, ITableColumn, Object)
*/
public IRender getRenderer(
IRequestCycle objCycle,
ITableModelSource objSource,
ITableColumn objColumn,
Object objRow)
{
if (m_objComponentRenderer == null)
{
synchronized (this)
{
if (m_objComponentRenderer == null)
{
ComponentAddress objAddress =
new ComponentAddress(
objSource.getNamespace(),
"SimpleTableColumnPage",
"tableColumnFormComponent");
m_objComponentRenderer =
new ComponentTableRendererSource(objAddress);
}
}
}
return m_objComponentRenderer.getRenderer(
objCycle,
objSource,
objColumn,
objRow);
}
}
1.3 +2 -1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnPage.page
Index: SimpleTableColumnPage.page
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnPage.page,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SimpleTableColumnPage.page 1 Jun 2003 05:05:10 -0000 1.2
+++ SimpleTableColumnPage.page 6 Sep 2003 14:04:42 -0000 1.3
@@ -7,5 +7,6 @@
<page-specification>
<component id="tableColumnComponent" type="SimpleTableColumnComponent"/>
+ <component id="tableColumnFormComponent" type="SimpleTableColumnFormComponent"/>
</page-specification>
1.2 +2 -1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnPage.html
Index: SimpleTableColumnPage.html
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnPage.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SimpleTableColumnPage.html 5 Mar 2003 23:03:10 -0000 1.1
+++ SimpleTableColumnPage.html 6 Sep 2003 14:04:42 -0000 1.2
@@ -3,5 +3,6 @@
<span jwcid="$content$">
<span jwcid="tableColumnComponent"/>
+ <span jwcid="tableColumnFormComponent"/>
</span>
1.2 +7 -1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnComponent.java
Index: SimpleTableColumnComponent.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnComponent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SimpleTableColumnComponent.java 5 Mar 2003 23:03:10 -0000 1.1
+++ SimpleTableColumnComponent.java 6 Sep 2003 14:04:42 -0000 1.2
@@ -70,6 +70,12 @@
import org.apache.tapestry.util.ComponentAddress;
/**
+ * A component that renders the default column header.
+ *
+ * If the current column is sortable, it renders the header as a link.
+ * Clicking on the link causes the table to be sorted on that column.
+ * Clicking on the link again causes the sorting order to be reversed.
+ *
* @version $Id$
* @author mindbridge
*/
1.1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnFormComponent.html
Index: SimpleTableColumnFormComponent.html
===================================================================
<!-- $Id: SimpleTableColumnFormComponent.html,v 1.1 2003/09/06 14:04:42 mindbridge Exp $ -->
<span jwcid="$content$">
<span jwcid="condSorted">
<table border=0 cellspacing=0 cellpadding=0 align="center">
<tr>
<td><a jwcid="linkColumn"><span jwcid="insertSortedColumn"/></a></td>
<span jwcid="condSort"><td> <span jwcid="imageSort" align="center"/></td></span>
</tr>
</table>
</span>
<span jwcid="condNotSorted">
<span jwcid="insertNotSortedColumn"/>
</span>
</span>
1.1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnFormComponent.jwc
Index: SimpleTableColumnFormComponent.jwc
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: SimpleTableColumnFormComponent.jwc,v 1.1 2003/09/06 14:04:42 mindbridge Exp $ -->
<!DOCTYPE component-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<component-specification class="org.apache.tapestry.contrib.table.components.inserted.SimpleTableColumnFormComponent"
allow-informal-parameters="yes">
<description>
</description>
<property-specification name="tableModelSource"
type="org.apache.tapestry.contrib.table.model.ITableModelSource"
initial-value="null"/>
<property-specification name="tableColumn"
type="org.apache.tapestry.contrib.table.model.ITableColumn"
initial-value="null"/>
<property-specification name="selectedColumnName" type="java.lang.String"/>
<component id="condSorted" type="FormConditional">
<binding name="condition" expression="columnSorted"/>
</component>
<component id="condNotSorted" type="FormConditional">
<binding name="condition" expression="columnSorted"/>
<static-binding name="invert">true</static-binding>
</component>
<component id="insertSortedColumn" type="Insert">
<binding name="value" expression="displayName"/>
</component>
<component id="insertNotSortedColumn" type="Insert">
<binding name="value" expression="displayName"/>
</component>
<component id="linkColumn" type="LinkSubmit">
<binding name="listener" expression="listeners.columnSelected"/>
<binding name="tag" expression="tableColumn.columnName"/>
<binding name="selected" expression="selectedColumnName"/>
</component>
<component id="imageSort" type="Image">
<binding name="image" expression="sortImage"/>
</component>
<component id="condSort" type="FormConditional">
<binding name="condition" expression="isSorted"/>
</component>
<private-asset name="sortDown" resource-path="arrow-down.gif"/>
<private-asset name="sortUp" resource-path="arrow-up.gif"/>
</component-specification>
1.1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnFormComponent.java
Index: SimpleTableColumnFormComponent.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation", "Tapestry"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* or "Tapestry", nor may "Apache" or "Tapestry" appear in their
* name, without prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE TAPESTRY CONTRIBUTOR COMMUNITY
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.tapestry.contrib.table.components.inserted;
import org.apache.tapestry.BaseComponent;
import org.apache.tapestry.IAsset;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.contrib.table.components.TableColumns;
import org.apache.tapestry.contrib.table.model.ITableColumn;
import org.apache.tapestry.contrib.table.model.ITableModel;
import org.apache.tapestry.contrib.table.model.ITableModelSource;
import org.apache.tapestry.contrib.table.model.ITableRendererListener;
import org.apache.tapestry.contrib.table.model.ITableSortingState;
import org.apache.tapestry.contrib.table.model.simple.SimpleTableColumn;
/**
* A component that renders the default column header in a form.
*
* If the current column is sortable, it renders the header as a link.
* Clicking on the link causes the table to be sorted on that column.
* Clicking on the link again causes the sorting order to be reversed.
*
* This component renders links that cause the form to be submitted.
* This ensures that the updated data in the other form fields is preserved.
*
* @version $Id: SimpleTableColumnFormComponent.java,v 1.1 2003/09/06 14:04:42 mindbridge Exp $
* @author mindbridge
*/
public abstract class SimpleTableColumnFormComponent
extends BaseComponent
implements ITableRendererListener
{
public abstract ITableColumn getTableColumn();
public abstract void setTableColumn(ITableColumn objColumn);
public abstract ITableModelSource getTableModelSource();
public abstract void setTableModelSource(ITableModelSource objSource);
public abstract String getSelectedColumnName();
/**
* @see org.apache.tapestry.contrib.table.model.ITableRendererListener#initializeRenderer(IRequestCycle, ITableModelSource, ITableColumn, Object)
*/
public void initializeRenderer(
IRequestCycle objCycle,
ITableModelSource objSource,
ITableColumn objColumn,
Object objRow)
{
setTableModelSource(objSource);
setTableColumn(objColumn);
}
public ITableModel getTableModel()
{
return getTableModelSource().getTableModel();
}
public boolean getColumnSorted()
{
return getTableColumn().getSortable();
}
public String getDisplayName()
{
ITableColumn objColumn = getTableColumn();
if (objColumn instanceof SimpleTableColumn) {
SimpleTableColumn objSimpleColumn = (SimpleTableColumn) objColumn;
return objSimpleColumn.getDisplayName();
}
return objColumn.getColumnName();
}
public boolean getIsSorted()
{
ITableSortingState objSortingState = getTableModel().getSortingState();
String strSortColumn = objSortingState.getSortColumn();
return getTableColumn().getColumnName().equals(strSortColumn);
}
public IAsset getSortImage()
{
IAsset objImageAsset;
IRequestCycle objCycle = getPage().getRequestCycle();
ITableSortingState objSortingState = getTableModel().getSortingState();
if (objSortingState.getSortOrder()
== ITableSortingState.SORT_ASCENDING)
{
objImageAsset =
(IAsset) objCycle.getAttribute(
TableColumns.TABLE_COLUMN_ARROW_UP_ATTRIBUTE);
if (objImageAsset == null)
objImageAsset = getAsset("sortUp");
}
else
{
objImageAsset =
(IAsset) objCycle.getAttribute(
TableColumns.TABLE_COLUMN_ARROW_DOWN_ATTRIBUTE);
if (objImageAsset == null)
objImageAsset = getAsset("sortDown");
}
return objImageAsset;
}
public void columnSelected(IRequestCycle objCycle)
{
String strColumnName = getSelectedColumnName();
ITableSortingState objState = getTableModel().getSortingState();
if (strColumnName.equals(objState.getSortColumn()))
objState.setSortColumn(strColumnName, !objState.getSortOrder());
else
objState.setSortColumn(
strColumnName,
ITableSortingState.SORT_ASCENDING);
// ensure that the change is saved
getTableModelSource().fireObservedStateChange();
}
}
1.1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableFormRows.java
Index: TableFormRows.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation", "Tapestry"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* or "Tapestry", nor may "Apache" or "Tapestry" appear in their
* name, without prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE TAPESTRY CONTRIBUTOR COMMUNITY
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.tapestry.contrib.table.components;
/**
* A low level Table component that generates the rows of the current page in the table.
*
* This component is a variant of {@link org.apache.tapestry.contrib.table.components.TablePages},
* but is designed for operation in a form. The displayed rows are stored in
* hidden form fields, which are then read during a rewind. This ensures that
* the form will rewind in exactly the same was as it was rendered even if the
* TableModel has changed and no StaleLink exceptions will occur.
*
* The component must be wrapped by {@link org.apache.tapestry.contrib.table.components.TableView}.
*
* <p>
* The component iterates over the rows of the current page in the table.
* The rows are wrapped in 'tr' tags by default.
* You can define columns manually within, or
* you can use {@link org.apache.tapestry.contrib.table.components.TableValues}
* to generate the columns automatically.
*
* <p>
* <table border=1 align="center">
* <tr>
* <th>Parameter</th>
* <th>Type</th>
* <th>Direction </th>
* <th>Required</th>
* <th>Default</th>
* <th>Description</th>
* </tr>
*
* <tr>
* <td>row</td>
* <td>Object</td>
* <td>out</td>
* <td>no</td>
* <td> </td>
* <td align="left">The value object of the current row.</td>
* </tr>
*
* <tr>
* <td>element</td>
* <td>String</td>
* <td>in</td>
* <td>no</td>
* <td>tr</td>
* <td align="left">The tag to use to wrap the rows in.</td>
* </tr>
*
* </table>
*
* @author mindbridge
* @version $Id: TableFormRows.java,v 1.1 2003/09/06 14:04:42 mindbridge Exp $
*
*/
public class TableFormRows extends TableRows
{
}
1.1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableFormPages.html
Index: TableFormPages.html
===================================================================
<!-- $Id: TableFormPages.html,v 1.1 2003/09/06 14:04:42 mindbridge Exp $ -->
<span jwcid="$content$">
<span jwcid="hiddenCurrentPage"/>
<span jwcid="hiddenPageCount"/>
<span jwcid="hiddenStartPage"/>
<span jwcid="hiddenStopPage"/>
<a jwcid="linkFirst"><<</a>
<a jwcid="linkBack"><</a>
<span jwcid="iterPage">
<span jwcid="condCurrent">
<b><span jwcid="insertCurrentPage"/></b>
</span>
<span jwcid="condOther">
<a jwcid="linkPage"><span jwcid="insertOtherPage"/></a>
</span>
</span>
<a jwcid="linkFwd">></a>
<a jwcid="linkLast">>></a>
</span>
1.1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableFormPages.jwc
Index: TableFormPages.jwc
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: TableFormPages.jwc,v 1.1 2003/09/06 14:04:42 mindbridge Exp $ -->
<!DOCTYPE component-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<component-specification class="org.apache.tapestry.contrib.table.components.TableFormPages"
allow-body="no" allow-informal-parameters="yes">
<description>
</description>
<parameter name="pagesDisplayed"
type="int"
required="no"
direction="custom"/>
<property-specification name="selectedPage" type="int"/>
<component id="hiddenCurrentPage" type="Conditional">
<binding name="value" expression="currentPage"/>
</component>
<component id="hiddenPageCount" type="Conditional">
<binding name="value" expression="pageCount"/>
</component>
<component id="hiddenStartPage" type="Conditional">
<binding name="value" expression="startPage"/>
</component>
<component id="hiddenStopPage" type="Conditional">
<binding name="value" expression="stopPage"/>
</component>
<component id="condCurrent" type="Conditional">
<binding name="condition" expression="condCurrent"/>
</component>
<component id="condOther" type="Conditional">
<binding name="condition" expression="condCurrent"/>
<static-binding name="invert">true</static-binding>
</component>
<component id="iterPage" type="Foreach">
<binding name="source" expression="pageList"/>
<binding name="value" expression="displayPage"/>
</component>
<component id="insertCurrentPage" type="Insert">
<binding name="value" expression="displayPage"/>
</component>
<component id="insertOtherPage" type="Insert">
<binding name="value" expression="displayPage"/>
</component>
<component id="linkPage" type="LinkSubmit">
<binding name="listener" expression="listeners.changePage"/>
<binding name="tag" expression="displayPage"/>
<binding name="selected" expression="selectedPage"/>
</component>
<component id="linkFirst" type="LinkSubmit">
<binding name="listener" expression="listeners.changePage"/>
<binding name="tag" expression="1"/>
<binding name="selected" expression="selectedPage"/>
<binding name="disabled" expression="!condBack"/>
</component>
<component id="linkBack" type="LinkSubmit">
<binding name="listener" expression="listeners.changePage"/>
<binding name="tag" expression="currentPage - 1"/>
<binding name="selected" expression="selectedPage"/>
<binding name="disabled" expression="!condBack"/>
</component>
<component id="linkFwd" type="LinkSubmit">
<binding name="listener" expression="listeners.changePage"/>
<binding name="tag" expression="currentPage + 1"/>
<binding name="selected" expression="selectedPage"/>
<binding name="disabled" expression="!condFwd"/>
</component>
<component id="linkLast" type="LinkSubmit">
<binding name="listener" expression="listeners.changePage"/>
<binding name="tag" expression="pageCount"/>
<binding name="selected" expression="selectedPage"/>
<binding name="disabled" expression="!condFwd"/>
</component>
</component-specification>
1.1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableFormPages.java
Index: TableFormPages.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation", "Tapestry"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* or "Tapestry", nor may "Apache" or "Tapestry" appear in their
* name, without prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE TAPESTRY CONTRIBUTOR COMMUNITY
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.tapestry.contrib.table.components;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.contrib.table.model.ITableModelSource;
import org.apache.tapestry.event.PageDetachListener;
import org.apache.tapestry.event.PageEvent;
import org.apache.tapestry.event.PageRenderListener;
/**
* A low level Table component that renders the pages in the table.
*
* This component is a variant of {@link org.apache.tapestry.contrib.table.components.TablePages},
* but is designed for operation in a form. The necessary page data is stored
* in hidden fields, so that no StaleLink exceptions occur during a rewind.
* The links also submit the form, which ensures that the data in the other
* form fields is preserved even when the page chages.
*
* The component must be wrapped by {@link org.apache.tapestry.contrib.table.components.TableView}.
* <p>
* The component generates a list of pages in the Table centered around the
* current one and allows you to navigate to other pages.
*
* <p>
* <table border=1 align="center">
* <tr>
* <th>Parameter</th>
* <th>Type</th>
* <th>Direction </th>
* <th>Required</th>
* <th>Default</th>
* <th>Description</th>
* </tr>
*
* <tr>
* <td>pagesDisplayed</td>
* <td>int</td>
* <td>in</td>
* <td>no</td>
* <td>7</td>
* <td align="left">Determines the maximum number of pages to be displayed in the page list
* when the table has more than one page.
* <p>For example, if the table has 20 pages, and 10 is the current page,
* pages from 7 to 13 in the page list will be shown if this parameter has
* a value of 7.
* </td>
* </tr>
*
* </table>
*
*
* @author mindbridge
* @version $Id: TableFormPages.java,v 1.1 2003/09/06 14:04:42 mindbridge Exp $
*
*/
public abstract class TableFormPages extends TablePages
implements PageDetachListener, PageRenderListener
{
private int m_nCurrentPage;
private int m_nPageCount;
private int m_nStartPage;
private int m_nStopPage;
public TableFormPages()
{
initialize();
}
/**
* @see org.apache.tapestry.event.PageDetachListener#pageDetached(org.apache.tapestry.event.PageEvent)
*/
public void pageDetached(PageEvent event)
{
initialize();
}
/**
* @see org.apache.tapestry.event.PageRenderListener#pageBeginRender(org.apache.tapestry.event.PageEvent)
*/
public void pageBeginRender(PageEvent event)
{
// values set during rewind are removed
initialize();
}
/**
* Initialize the values and return the object to operation identical
* to that of the super class.
*/
private void initialize()
{
m_nCurrentPage = -1;
m_nPageCount = -1;
m_nStartPage = -1;
m_nStopPage = -1;
}
// This would ideally be a delayed invocation -- called after the form rewind
public void changePage(IRequestCycle objCycle)
{
ITableModelSource objSource = getTableModelSource();
setCurrentPage(objSource, getSelectedPage());
// ensure that the change is saved
objSource.fireObservedStateChange();
}
// defined in the JWC file
public abstract int getSelectedPage();
/**
* @return
*/
public int getCurrentPage()
{
if (m_nCurrentPage < 0)
m_nCurrentPage = super.getCurrentPage();
return m_nCurrentPage;
}
/**
* @return
*/
public int getPageCount()
{
if (m_nPageCount < 0)
m_nPageCount = super.getPageCount();
return m_nPageCount;
}
/**
* @return
*/
public int getStartPage()
{
if (m_nStartPage < 0)
m_nStartPage = super.getStartPage();
return m_nStartPage;
}
/**
* @return
*/
public int getStopPage()
{
if (m_nStopPage < 0)
m_nStopPage = super.getStopPage();
return m_nStopPage;
}
/**
* @param i
*/
public void setCurrentPage(int i)
{
m_nCurrentPage = i;
}
/**
* @param i
*/
public void setPageCount(int i)
{
m_nPageCount = i;
}
/**
* @param i
*/
public void setStartPage(int i)
{
m_nStartPage = i;
}
/**
* @param i
*/
public void setStopPage(int i)
{
m_nStopPage = i;
}
}
1.1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableFormRows.html
Index: TableFormRows.html
===================================================================
<!-- $Id: TableFormRows.html,v 1.1 2003/09/06 14:04:42 mindbridge Exp $ -->
<span jwcid="$content$">
<tr jwcid="iterRows">
<span jwcid="@RenderBody"/>
</tr>
</span>
1.1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableFormRows.jwc
Index: TableFormRows.jwc
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: TableFormRows.jwc,v 1.1 2003/09/06 14:04:42 mindbridge Exp $ -->
<!DOCTYPE component-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<component-specification class="org.apache.tapestry.contrib.table.components.TableFormRows"
allow-body="yes" allow-informal-parameters="yes">
<description>
</description>
<parameter name="row"
type="Object"
required="no"
direction="custom"/>
<parameter name="element"
type="java.lang.String"
required="no"
direction="custom"
default-value='"tr"'/>
<component id="iterRows" type="ListEdit" inherit-informal-parameters="yes">
<binding name="source" expression="tableRowsIterator"/>
<binding name="value" expression="tableRow"/>
<binding name="element" expression="element"/>
</component>
</component-specification>
1.31 +4 -1 jakarta-tapestry/framework/src/org/apache/tapestry/TapestryStrings.properties
Index: TapestryStrings.properties
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/TapestryStrings.properties,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- TapestryStrings.properties 26 Jul 2003 02:13:43 -0000 1.30
+++ TapestryStrings.properties 6 Sep 2003 14:04:43 -0000 1.31
@@ -216,6 +216,9 @@
ListEdit.unable-to-convert-value=Unable to convert {0} to an external string in ListEdit component.
ListEdit.unable-to-convert-string=Unable to convert {0} back into an object in ListEdit component.
+FormConditional.unable-to-convert-value=Unable to convert {0} to an external string in FormConditional component.
+FormConditional.unable-to-convert-string=Unable to convert {0} back into an object in FormConditional component.
+
Option.must-be-contained-by-select=Option component must be contained within a Select.
Radio.must-be-contained-by-group=Radio component must be contained within a RadioGroup.
1.1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/form/FormConditional.java
Index: FormConditional.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation", "Tapestry"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* or "Tapestry", nor may "Apache" or "Tapestry" appear in their
* name, without prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE TAPESTRY CONTRIBUTOR COMMUNITY
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.tapestry.contrib.form;
import java.io.IOException;
import org.apache.commons.lang.StringUtils;
import org.apache.tapestry.ApplicationRuntimeException;
import org.apache.tapestry.IActionListener;
import org.apache.tapestry.IBinding;
import org.apache.tapestry.IForm;
import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.Tapestry;
import org.apache.tapestry.form.AbstractFormComponent;
import org.apache.tapestry.request.RequestContext;
import org.apache.tapestry.util.io.DataSqueezer;
/**
* A conditional element on a page which will render its wrapped elements
* zero or one times.
*
* This component is a variant of {@link org.apache.tapestry.components.Conditional},
* but is designed for operation in a form. The component parameters are stored in
* hidden fields during rendering and are taken from those fields during the rewind,
* thus no StaleLink exceptions occur.
*
* [<a href="../../../../../ComponentReference/Conditional.html">Component Reference</a>]
*
* @author Mindbridge
* @version $Id: FormConditional.java,v 1.1 2003/09/06 14:04:43 mindbridge Exp $
* @since 3.0
*
**/
public abstract class FormConditional extends AbstractFormComponent
{
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
IForm form = getForm(cycle);
boolean cycleRewinding = cycle.isRewinding();
// If the cycle is rewinding, but not this particular form,
// then do nothing (don't even render the body).
if (cycleRewinding && !form.isRewinding())
return;
String name = form.getElementId(this);
boolean condition = getCondition(cycle, form, name);
boolean invert = getInvert(cycle, form, name);
// call listener
IActionListener listener = getListener();
if (listener != null)
listener.actionTriggered(this, cycle);
// render the component body only if the condition is different from the invert
if (condition != invert) {
String element = getElement();
boolean render = cycleRewinding && StringUtils.isNotEmpty(element);
if (render)
{
writer.begin(element);
renderInformalParameters(writer, cycle);
}
renderBody(writer, cycle);
if (render)
writer.end(element);
}
}
private boolean getCondition(IRequestCycle cycle, IForm form, String name)
{
boolean condition;
if (!cycle.isRewinding())
{
condition = getCondition();
writeValue(form, name, condition);
}
else
{
RequestContext context = cycle.getRequestContext();
String submittedConditions[] = context.getParameters(name);
condition = convertValue(submittedConditions[0]);
}
IBinding conditionValueBinding = getConditionValueBinding();
if (conditionValueBinding != null)
conditionValueBinding.setBoolean(condition);
return condition;
}
private boolean getInvert(IRequestCycle cycle, IForm form, String name)
{
boolean invert;
if (!cycle.isRewinding())
{
invert = getInvert();
writeValue(form, name, invert);
}
else
{
RequestContext context = cycle.getRequestContext();
String submittedConditions[] = context.getParameters(name);
invert = convertValue(submittedConditions[1]);
}
IBinding invertValueBinding = getInvertValueBinding();
if (invertValueBinding != null)
invertValueBinding.setBoolean(invert);
return invert;
}
private void writeValue(IForm form, String name, boolean value)
{
String externalValue;
Object booleanValue = new Boolean(value);
try
{
externalValue = getDataSqueezer().squeeze(booleanValue);
}
catch (IOException ex)
{
throw new ApplicationRuntimeException(
Tapestry.format("FormConditional.unable-to-convert-value", booleanValue),
this,
null,
ex);
}
form.addHiddenValue(name, externalValue);
}
private boolean convertValue(String value)
{
try
{
Object booleanValue = getDataSqueezer().unsqueeze(value);
return Tapestry.evaluateBoolean(booleanValue);
}
catch (IOException ex)
{
throw new ApplicationRuntimeException(
Tapestry.format("FormConditional.unable-to-convert-string", value),
this,
null,
ex);
}
}
private DataSqueezer getDataSqueezer()
{
return getPage().getEngine().getDataSqueezer();
}
public boolean isDisabled()
{
return false;
}
public abstract boolean getCondition();
public abstract boolean getInvert();
public abstract String getElement();
public abstract IBinding getConditionValueBinding();
public abstract IBinding getInvertValueBinding();
public abstract IActionListener getListener();
}
1.1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/form/FormConditional.jwc
Index: FormConditional.jwc
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: FormConditional.jwc,v 1.1 2003/09/06 14:04:43 mindbridge Exp $ -->
<!DOCTYPE component-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<component-specification class="org.apache.tapestry.contrib.form.FormConditional">
<description>
Conditionally emulates an element and its attributes (if element is specified) and/or includes a block of content if a condition is met.
</description>
<parameter name="condition" type="boolean" direction="in">
<description>
The condition to evaluate.
</description>
</parameter>
<parameter name="invert" type="boolean" direction="in">
<description>
If true, inverts the condition, so that a false condition causes the
content to be included. If false (the default), then the condition
is evaluated normally.
</description>
</parameter>
<parameter name="element" type="java.lang.String" direction="in" required="no">
<description>
The element to emulate.
</description>
</parameter>
<parameter name="listener" type="org.apache.tapestry.IActionListener" direction="in"/>
<parameter name="conditionValue" type="boolean">
<description>
The value of the condition. During render this is a obtained from
the condition parameter. Diring rewind it is the submited condition.
</description>
</parameter>
<parameter name="invertValue" type="boolean">
<description>
Whether the condition is inverted or not. During render this is a obtained from
the invert parameter. Diring rewind it is the submited value of invert.
</description>
</parameter>
<property-specification name="name" type="java.lang.String"/>
<property-specification name="form" type="org.apache.tapestry.IForm"/>
</component-specification>
1.5 +5 -1 jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/Contrib.library
Index: Contrib.library
===================================================================
RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/Contrib.library,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Contrib.library 26 Jul 2003 02:13:43 -0000 1.4
+++ Contrib.library 6 Sep 2003 14:04:43 -0000 1.5
@@ -21,6 +21,7 @@
<component-type type="MaskEdit" specification-path="form/MaskEdit.jwc"/>
<component-type type="NumericField" specification-path="valid/NumericField.jwc"/>
<component-type type="ValidatingTextField" specification-path="valid/ValidatingTextField.jwc"/>
+ <component-type type="FormConditional" specification-path="form/FormConditional.jwc"/>
<component-type type="InheritInformalAny" specification-path="informal/InheritInformalAny.jwc"/>
@@ -30,9 +31,12 @@
<component-type type="TableRows" specification-path="table/components/TableRows.jwc"/>
<component-type type="TableValues" specification-path="table/components/TableValues.jwc"/>
<component-type type="TableView" specification-path="table/components/TableView.jwc"/>
+ <component-type type="TableFormRows" specification-path="table/components/TableFormRows.jwc"/>
+ <component-type type="TableFormPages" specification-path="table/components/TableFormPages.jwc"/>
<page name="SimpleTableColumnPage" specification-path="table/components/inserted/SimpleTableColumnPage.page"/>
<component-type type="SimpleTableColumnComponent" specification-path="table/components/inserted/SimpleTableColumnComponent.jwc"/>
+ <component-type type="SimpleTableColumnFormComponent" specification-path="table/components/inserted/SimpleTableColumnFormComponent.jwc"/>
<component-type type="PopupLink" specification-path="popup/PopupLink.jwc"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org