You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sc...@apache.org on 2005/08/12 04:04:53 UTC
svn commit: r232183 - in /myfaces: examples/trunk/simple/
share/trunk/src/java/org/apache/myfaces/renderkit/
share/trunk/src/java/org/apache/myfaces/renderkit/html/
tomahawk/trunk/src/java/org/apache/myfaces/taglib/html/ext/
tomahawk/trunk/tld/
Author: schof
Date: Thu Aug 11 19:04:47 2005
New Revision: 232183
URL: http://svn.apache.org/viewcvs?rev=232183&view=rev
Log:
Fixes MyFaces-409
Modified:
myfaces/examples/trunk/simple/pagedSortTable.jsp
myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/JSFAttr.java
myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlTableRendererBase.java
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java
myfaces/tomahawk/trunk/tld/tomahawk.tld
Modified: myfaces/examples/trunk/simple/pagedSortTable.jsp
URL: http://svn.apache.org/viewcvs/myfaces/examples/trunk/simple/pagedSortTable.jsp?rev=232183&r1=232182&r2=232183&view=diff
==============================================================================
--- myfaces/examples/trunk/simple/pagedSortTable.jsp (original)
+++ myfaces/examples/trunk/simple/pagedSortTable.jsp Thu Aug 11 19:04:47 2005
@@ -34,7 +34,7 @@
<f:view>
<f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
- <h:form>
+ <h:form>
<t:dataTable id="data"
styleClass="scrollerTable"
headerClass="standardTable_Header"
@@ -45,6 +45,8 @@
value="#{pagedSort.cars}"
preserveDataModel="true"
rows="10"
+ rowId="#{car.type}"
+ rowOnClick="alert('rowId: ' + this.id)"
sortColumn="#{pagedSort.sort}"
sortAscending="#{pagedSort.ascending}"
preserveSort="true">
@@ -67,7 +69,7 @@
</t:commandSortHeader>
</f:facet>
<h:inputText value="#{car.color}" >
- <f:validateLength maximum="10"/>
+ <f:validateLength maximum="10"/>
</h:inputText>
</h:column>
</t:dataTable>
@@ -105,7 +107,7 @@
</t:dataScroller>
</h:panelGrid>
- </h:form>
+ </h:form>
</f:view>
<%@include file="inc/page_footer.jsp" %>
Modified: myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/JSFAttr.java
URL: http://svn.apache.org/viewcvs/myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/JSFAttr.java?rev=232183&r1=232182&r2=232183&view=diff
==============================================================================
--- myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/JSFAttr.java (original)
+++ myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/JSFAttr.java Thu Aug 11 19:04:47 2005
@@ -122,6 +122,9 @@
public static final String SHOW_ROOT_NODE = "org.apache.myfaces.tree2.SHOW_ROOT_NODE";
public static final String PRESERVE_TOGGLE = "org.apache.myfaces.tree2.PRESERVE_TOGGLE";
+ // dataTable (extended) attributes
+ public static final String ROW_ID = "org.apache.myfaces.dataTable.ROW_ID";
+
// Alternate locations (instead of using AddResource)
public static final String JAVASCRIPT_LOCATION = "org.apache.myfaces.JAVASCRIPT_LOCATION";
public static final String IMAGE_LOCATION = "org.apache.myfaces.IMAGE_LOCATION";
Modified: myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlTableRendererBase.java
URL: http://svn.apache.org/viewcvs/myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlTableRendererBase.java?rev=232183&r1=232182&r2=232183&view=diff
==============================================================================
--- myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlTableRendererBase.java (original)
+++ myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlTableRendererBase.java Thu Aug 11 19:04:47 2005
@@ -49,17 +49,17 @@
/** The logger. */
private static final Log log = LogFactory.getLog(HtmlTableRendererBase.class);
- /**
- * @see javax.faces.render.Renderer#getRendersChildren()
- */
+ /**
+ * @see javax.faces.render.Renderer#getRendersChildren()
+ */
public boolean getRendersChildren()
{
return true;
}
- /**
- * @see javax.faces.render.Renderer#encodeBegin(FacesContext, UIComponent)
- */
+ /**
+ * @see javax.faces.render.Renderer#encodeBegin(FacesContext, UIComponent)
+ */
public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException
{
RendererUtils.checkParamValidity(facesContext, uiComponent, UIData.class);
@@ -77,9 +77,9 @@
renderFacet(facesContext, writer, (UIData) uiComponent, false);
}
- /**
- * @see javax.faces.render.Renderer#encodeChildren(FacesContext, UIComponent)
- */
+ /**
+ * @see javax.faces.render.Renderer#encodeChildren(FacesContext, UIComponent)
+ */
public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException
{
RendererUtils.checkParamValidity(facesContext, component, UIData.class);
@@ -98,7 +98,7 @@
/**
* Renders everything inside the <tbody> tag. currently used for the autoUpdateDataTable
- */
+ */
public void encodeInnerHtml(FacesContext facesContext, UIComponent component)throws IOException{
UIData uiData = (UIData) component;
@@ -151,7 +151,7 @@
UIComponent child = (UIComponent) children.get(j);
if(child.isRendered())
{
- encodeColumnChild(facesContext, writer, uiData, child, columnStyleIterator);
+ encodeColumnChild(facesContext, writer, uiData, child, columnStyleIterator);
}
}
renderRowEnd(facesContext, writer, uiData);
@@ -160,14 +160,14 @@
}
}
- protected void encodeColumnChild(FacesContext facesContext, ResponseWriter writer,
- UIData uiData, UIComponent component, Iterator columnStyleIterator) throws IOException
- {
+ protected void encodeColumnChild(FacesContext facesContext, ResponseWriter writer,
+ UIData uiData, UIComponent component, Iterator columnStyleIterator) throws IOException
+ {
if (component instanceof UIColumn)
{
- renderColumnBody(facesContext, writer, uiData, component, columnStyleIterator);
+ renderColumnBody(facesContext, writer, uiData, component, columnStyleIterator);
}
- }
+ }
/**
* Renders the body of a given <code>UIColumn</code> (everything but the header and footer facets).
@@ -179,22 +179,22 @@
* there is none.
* @throws IOException if an exception occurs.
*/
- protected void renderColumnBody(
- FacesContext facesContext,
- ResponseWriter writer,
- UIData uiData,
- UIComponent component,
- Iterator columnStyleIterator) throws IOException
- {
- writer.startElement(HTML.TD_ELEM, uiData);
- if (columnStyleIterator.hasNext())
- {
- writer.writeAttribute(HTML.CLASS_ATTR, columnStyleIterator.next(), null);
- }
-
+ protected void renderColumnBody(
+ FacesContext facesContext,
+ ResponseWriter writer,
+ UIData uiData,
+ UIComponent component,
+ Iterator columnStyleIterator) throws IOException
+ {
+ writer.startElement(HTML.TD_ELEM, uiData);
+ if (columnStyleIterator.hasNext())
+ {
+ writer.writeAttribute(HTML.CLASS_ATTR, columnStyleIterator.next(), null);
+ }
+
RendererUtils.renderChild(facesContext, component);
writer.endElement(HTML.TD_ELEM);
- }
+ }
/**
* Renders the start of a new row of body content.
@@ -204,33 +204,41 @@
* @param rowStyleIterator te styleClass of the row or <code>null</code> if there is none.
* @throws IOException if an exceptoin occurs.
*/
- protected void renderRowStart(
- FacesContext facesContext,
- ResponseWriter writer,
- UIData uiData,
- Iterator rowStyleIterator) throws IOException
- {
- writer.startElement(HTML.TR_ELEM, uiData);
+ protected void renderRowStart(
+ FacesContext facesContext,
+ ResponseWriter writer,
+ UIData uiData,
+ Iterator rowStyleIterator) throws IOException
+ {
+ writer.startElement(HTML.TR_ELEM, uiData);
+
+ String rowId = (String)uiData.getAttributes().get(JSFAttr.ROW_ID);
+
if (rowStyleIterator.hasNext())
{
writer.writeAttribute(HTML.CLASS_ATTR, rowStyleIterator.next(), null);
}
- }
+
+ if (rowId != null)
+ {
+ writer.writeAttribute(HTML.ID_ATTR, rowId, null);
+ }
+ }
- /**
+ /**
* Renders the end of a row of body content.
* @param facesContext the <code>FacesContext</code>.
* @param writer the <code>ResponseWriter</code>.
* @param uiData the <code>UIData</code> being rendered.
* @throws IOException if an exceptoin occurs.
*/
- protected void renderRowEnd(
- FacesContext facesContext,
- ResponseWriter writer,
- UIData uiData) throws IOException
- {
- writer.endElement(HTML.TR_ELEM);
- }
+ protected void renderRowEnd(
+ FacesContext facesContext,
+ ResponseWriter writer,
+ UIData uiData) throws IOException
+ {
+ writer.endElement(HTML.TR_ELEM);
+ }
/**
* Convenient method for derived table renderers.
@@ -268,9 +276,9 @@
{
}
- /**
- * @see javax.faces.render.Renderer#encodeEnd(FacesContext, UIComponent)
- */
+ /**
+ * @see javax.faces.render.Renderer#encodeEnd(FacesContext, UIComponent)
+ */
public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException
{
RendererUtils.checkParamValidity(facesContext, uiComponent, UIData.class);
@@ -282,14 +290,14 @@
afterTable(facesContext, (UIData) uiComponent);
}
- /**
- * Renders either the header or the footer facets.
- * @param facesContext the <code>FacesContext</code>.
- * @param writer the <code>ResponseWriter</code>.
- * @param component the parent <code>UIComponent</code> containing the facets.
- * @param header whether this is the header facet (if not, then the footer facet).
- * @throws IOException if an exception occurs.
- */
+ /**
+ * Renders either the header or the footer facets.
+ * @param facesContext the <code>FacesContext</code>.
+ * @param writer the <code>ResponseWriter</code>.
+ * @param component the parent <code>UIComponent</code> containing the facets.
+ * @param header whether this is the header facet (if not, then the footer facet).
+ * @throws IOException if an exception occurs.
+ */
protected void renderFacet(FacesContext facesContext, ResponseWriter writer, UIComponent component, boolean header)
throws IOException
{
@@ -300,10 +308,10 @@
UIComponent uiComponent = (UIComponent) it.next();
if(uiComponent.isRendered())
{
- colspan += determineChildColSpan(uiComponent);
+ colspan += determineChildColSpan(uiComponent);
if (!hasColumnFacet)
{
- hasColumnFacet = hasFacet(header, uiComponent);
+ hasColumnFacet = hasFacet(header, uiComponent);
}
}
}
@@ -337,41 +345,41 @@
}
}
- /**
- * @param header
- * @param uiComponent
- * @return boolean
- */
- 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>.
- * @param component the <code>UIComponent</code> for whom a table is being rendered.
- * @param headerFacet the facet for the header.
- * @param headerStyleClass the styleClass of the header.
- * @param colspan the number of columns the header should span. Typically, this is
- * the number of columns in the table.
- * @throws IOException if an exception occurs.
- */
+ /**
+ * @param header
+ * @param uiComponent
+ * @return boolean
+ */
+ 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>.
+ * @param component the <code>UIComponent</code> for whom a table is being rendered.
+ * @param headerFacet the facet for the header.
+ * @param headerStyleClass the styleClass of the header.
+ * @param colspan the number of columns the header should span. Typically, this is
+ * the number of columns in the table.
+ * @throws IOException if an exception occurs.
+ */
protected void renderTableHeaderRow(FacesContext facesContext, ResponseWriter writer, UIComponent component,
UIComponent headerFacet, String headerStyleClass, int colspan) throws IOException
{
@@ -379,17 +387,17 @@
colspan);
}
- /**
- * Renders the footer row of the table being rendered.
- * @param facesContext the <code>FacesContext</code>.
- * @param writer the <code>ResponseWriter</code>.
- * @param component the <code>UIComponent</code> for whom a table is being rendered.
- * @param footerFacet the facet for the footer.
- * @param footerStyleClass the styleClass of the footer.
- * @param colspan the number of columns the header should span. Typically, this is
- * the number of columns in the table.
- * @throws IOException if an exception occurs.
- */
+ /**
+ * Renders the footer row of the table being rendered.
+ * @param facesContext the <code>FacesContext</code>.
+ * @param writer the <code>ResponseWriter</code>.
+ * @param component the <code>UIComponent</code> for whom a table is being rendered.
+ * @param footerFacet the facet for the footer.
+ * @param footerStyleClass the styleClass of the footer.
+ * @param colspan the number of columns the header should span. Typically, this is
+ * the number of columns in the table.
+ * @throws IOException if an exception occurs.
+ */
protected void renderTableFooterRow(FacesContext facesContext, ResponseWriter writer, UIComponent component,
UIComponent footerFacet, String footerStyleClass, int colspan) throws IOException
{
@@ -397,30 +405,30 @@
colspan);
}
- /**
- * Renders the header row for the columns, which is a separate row from the header row for the
- * <code>UIData</code> header facet.
- * @param facesContext the <code>FacesContext</code>.
- * @param writer the <code>ResponseWriter</code>.
- * @param component the <code>UIComponent</code> for whom a table is being rendered.
- * @param headerStyleClass the styleClass of the header
- * @throws IOException if an exception occurs.
- */
+ /**
+ * Renders the header row for the columns, which is a separate row from the header row for the
+ * <code>UIData</code> header facet.
+ * @param facesContext the <code>FacesContext</code>.
+ * @param writer the <code>ResponseWriter</code>.
+ * @param component the <code>UIComponent</code> for whom a table is being rendered.
+ * @param headerStyleClass the styleClass of the header
+ * @throws IOException if an exception occurs.
+ */
protected void renderColumnHeaderRow(FacesContext facesContext, ResponseWriter writer, UIComponent component,
String headerStyleClass) throws IOException
{
renderColumnHeaderOrFooterRow(facesContext, writer, component, headerStyleClass, true);
}
- /**
- * Renders the footer row for the columns, which is a separate row from the footer row for the
- * <code>UIData</code> footer facet.
- * @param facesContext the <code>FacesContext</code>.
- * @param writer the <code>ResponseWriter</code>.
- * @param component the <code>UIComponent</code> for whom a table is being rendered.
- * @param footerStyleClass the styleClass of the footerStyleClass
- * @throws IOException if an exception occurs.
- */
+ /**
+ * Renders the footer row for the columns, which is a separate row from the footer row for the
+ * <code>UIData</code> footer facet.
+ * @param facesContext the <code>FacesContext</code>.
+ * @param writer the <code>ResponseWriter</code>.
+ * @param component the <code>UIComponent</code> for whom a table is being rendered.
+ * @param footerStyleClass the styleClass of the footerStyleClass
+ * @throws IOException if an exception occurs.
+ */
protected void renderColumnFooterRow(FacesContext facesContext, ResponseWriter writer, UIComponent component,
String footerStyleClass) throws IOException
{
@@ -496,22 +504,22 @@
* @throws IOException
*/
protected void renderColumnHeaderCell(FacesContext facesContext, ResponseWriter writer, UIColumn uiColumn,
- String headerStyleClass, int colspan) throws IOException
+ String headerStyleClass, int colspan) throws IOException
{
- renderColumnHeaderCell(facesContext, writer, uiColumn, uiColumn.getHeader(), headerStyleClass, colspan);
+ renderColumnHeaderCell(facesContext, writer, uiColumn, uiColumn.getHeader(), headerStyleClass, colspan);
}
/**
- * Renders the header facet for the given <code>UIColumn</code>.
- * @param facesContext the <code>FacesContext</code>.
- * @param writer the <code>ResponseWriter</code>.
- * @param uiComponent the <code>UIComponent</code> to render the facet for.
+ * Renders the header facet for the given <code>UIColumn</code>.
+ * @param facesContext the <code>FacesContext</code>.
+ * @param writer the <code>ResponseWriter</code>.
+ * @param uiComponent the <code>UIComponent</code> to render the facet for.
* @param facet the <code>UIComponent</code> to render as facet.
- * @param headerStyleClass the styleClass of the header facet.
- * @param colspan the colspan for the tableData element in which the header facet
- * will be wrapped.
- * @throws IOException
- */
+ * @param headerStyleClass the styleClass of the header facet.
+ * @param colspan the colspan for the tableData element in which the header facet
+ * will be wrapped.
+ * @throws IOException
+ */
protected void renderColumnHeaderCell(FacesContext facesContext, ResponseWriter writer, UIComponent uiComponent,
UIComponent facet, String headerStyleClass, int colspan) throws IOException
{
@@ -547,17 +555,17 @@
renderColumnFooterCell(facesContext, writer, uiColumn, uiColumn.getFooter(), footerStyleClass, colspan);
}
- /**
- * Renders the footer facet for the given <code>UIColumn</code>.
- * @param facesContext the <code>FacesContext</code>.
- * @param writer the <code>ResponseWriter</code>.
- * @param uiComponent the <code>UIComponent</code> to render the facet for.
+ /**
+ * Renders the footer facet for the given <code>UIColumn</code>.
+ * @param facesContext the <code>FacesContext</code>.
+ * @param writer the <code>ResponseWriter</code>.
+ * @param uiComponent the <code>UIComponent</code> to render the facet for.
* @param facet the <code>UIComponent</code> to render as facet.
- * @param footerStyleClass the styleClass of the footer facet.
- * @param colspan the colspan for the tableData element in which the footer facet
- * will be wrapped.
- * @throws IOException
- */
+ * @param footerStyleClass the styleClass of the footer facet.
+ * @param colspan the colspan for the tableData element in which the footer facet
+ * will be wrapped.
+ * @throws IOException
+ */
protected void renderColumnFooterCell(FacesContext facesContext, ResponseWriter writer, UIComponent uiComponent,
UIComponent facet, String footerStyleClass, int colspan) throws IOException
{
@@ -577,11 +585,11 @@
writer.endElement(HTML.TD_ELEM);
}
- /**
- * Gets the headerClass attribute of the given <code>UIComponent</code>.
- * @param component the <code>UIComponent</code>.
- * @return the headerClass attribute of the given <code>UIComponent</code>.
- */
+ /**
+ * Gets the headerClass attribute of the given <code>UIComponent</code>.
+ * @param component the <code>UIComponent</code>.
+ * @return the headerClass attribute of the given <code>UIComponent</code>.
+ */
protected static String getHeaderClass(UIComponent component)
{
if (component instanceof HtmlDataTable)
@@ -594,11 +602,11 @@
}
}
- /**
- * Gets the footerClass attribute of the given <code>UIComponent</code>.
- * @param component the <code>UIComponent</code>.
- * @return the footerClass attribute of the given <code>UIComponent</code>.
- */
+ /**
+ * Gets the footerClass attribute of the given <code>UIComponent</code>.
+ * @param component the <code>UIComponent</code>.
+ * @return the footerClass attribute of the given <code>UIComponent</code>.
+ */
protected static String getFooterClass(UIComponent component)
{
if (component instanceof HtmlDataTable)
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java?rev=232183&r1=232182&r2=232183&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java Thu Aug 11 19:04:47 2005
@@ -18,6 +18,7 @@
import org.apache.myfaces.component.UserRoleAware;
import org.apache.myfaces.component.html.ext.HtmlDataTable;
import org.apache.myfaces.taglib.html.HtmlDataTableTagBase;
+import org.apache.myfaces.renderkit.JSFAttr;
import javax.faces.component.UIComponent;
@@ -61,8 +62,10 @@
private String _rowOnKeyPress;
private String _rowOnKeyDown;
private String _rowOnKeyUp;
+ private String _rowId;
- public void release() {
+ public void release()
+ {
super.release();
_preserveDataModel=null;
@@ -86,6 +89,7 @@
_rowOnKeyPress=null;
_rowOnKeyDown=null;
_rowOnKeyUp=null;
+ _rowId=null;
}
@@ -114,6 +118,7 @@
setStringProperty(component, "rowOnKeyPress", _rowOnKeyPress);
setStringProperty(component, "rowOnKeyDown", _rowOnKeyDown);
setStringProperty(component, "rowOnKeyUp", _rowOnKeyUp);
+ setStringProperty(component, JSFAttr.ROW_ID, _rowId);
}
public void setPreserveDataModel(String preserveDataModel)
@@ -123,7 +128,7 @@
public void setForceIdIndexFormula(String forceIdIndexFormula)
{
- _forceIdIndexFormula = forceIdIndexFormula;
+ _forceIdIndexFormula = forceIdIndexFormula;
}
public void setSortColumn(String sortColumn)
@@ -219,5 +224,10 @@
public void setRowOnMouseUp(String rowOnMouseUp)
{
_rowOnMouseUp = rowOnMouseUp;
+ }
+
+ public void setRowId(String rowId)
+ {
+ _rowId = rowId;
}
}
Modified: myfaces/tomahawk/trunk/tld/tomahawk.tld
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/tld/tomahawk.tld?rev=232183&r1=232182&r2=232183&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/tld/tomahawk.tld (original)
+++ myfaces/tomahawk/trunk/tld/tomahawk.tld Thu Aug 11 19:04:47 2005
@@ -299,6 +299,14 @@
Defines a JavaScript onkeyup event handler for each table row
</description>
</attribute>
+ <attribute>
+ <name>rowId</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ The id to use for <tr> elements that are generated by the table.
+ </description>
+ </attribute>
</tag>
<!-- inputHidden -->