Author: nbelaevski
Date: 2010-07-02 10:29:39 -0400 (Fri, 02 Jul 2010)
New Revision: 17707
Added:
root/ui/iteration/trunk/lists/api/pom.xml
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/package-info.java
Modified:
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java
root/ui/iteration/trunk/lists/ui/src/main/templates/list.template.xml
Log:
https://jira.jboss.org/browse/RF-8852
Added: root/ui/iteration/trunk/lists/api/pom.xml
===================================================================
--- root/ui/iteration/trunk/lists/api/pom.xml (rev 0)
+++ root/ui/iteration/trunk/lists/api/pom.xml 2010-07-02 14:29:39 UTC (rev 17707)
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ JBoss, Home of Professional Open Source Copyright 2010, Red Hat,
+ Inc. and individual contributors by the @authors tag. See the
+ copyright.txt in the distribution for a full listing of
+ individual contributors. This is free software; you can
+ redistribute it and/or modify it under the terms of the GNU
+ Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1 of the License, or (at your
+ option) any later version. This software is distributed in the
+ hope that it will be useful, but WITHOUT ANY WARRANTY; without
+ even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ for more details. You should have received a copy of the GNU
+ Lesser General Public License along with this software; if not,
+ write to the Free Software Foundation, Inc., 51 Franklin St,
+ Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site:
+
http://www.fsf.org.
+-->
+
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.richfaces.ui.iteration</groupId>
+ <artifactId>lists-aggregator</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.ui.iteration</groupId>
+ <artifactId>lists-api</artifactId>
+ <name>Richfaces UI Components: Lists API</name>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <!-- runtime -->
+ <dependency>
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-api</artifactId>
+ </dependency>
+
+ <!-- JSF with dependencies -->
+ <dependency>
+ <groupId>${jsf2.api.groupid}</groupId>
+ <artifactId>${jsf2.api.artifactid}</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- tests -->
+ <dependency>
+ <groupId>${jsf2.impl.groupid}</groupId>
+ <artifactId>${jsf2.impl.artifactid}</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <!-- todo api? -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test-jsf</groupId>
+ <artifactId>jsf-test-stage</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test-jsf</groupId>
+ <artifactId>htmlunit-client</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test-jsf</groupId>
+ <artifactId>jsf-mock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <scm>
+
<
connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/root/ui/it...
+
<
developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/root...
+ <
url>http://fisheye.jboss.org/browse/richfaces</url>
+ </scm>
+
+</project>
\ No newline at end of file
Added: root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/package-info.java
===================================================================
--- root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/package-info.java
(rev 0)
+++
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/package-info.java 2010-07-02
14:29:39 UTC (rev 17707)
@@ -0,0 +1,5 @@
+/**
+ * Implementation of RichFaces data lists
+ */
+@org.richfaces.cdk.annotations.TagLibrary(uri="http://richfaces.org/lists",
shortName="lists")
+package org.richfaces;
\ No newline at end of file
Modified:
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java
===================================================================
---
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java 2010-07-02
14:26:59 UTC (rev 17706)
+++
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java 2010-07-02
14:29:39 UTC (rev 17707)
@@ -76,7 +76,15 @@
* @author Nick Belaevski
*
*/
- private final class SimpleItemsEncoder extends ItemsEncoder {
+ private class SimpleItemsEncoder extends ItemsEncoder {
+
+ private String itemClass;
+
+ public SimpleItemsEncoder(String itemClass) {
+ super();
+ this.itemClass = itemClass;
+ }
+
@Override
protected void encodeRow(FacesContext context, UISequence sequence,
SequenceRendererHelper helper)
throws IOException {
@@ -89,7 +97,7 @@
}
rendererUtils.writeAttribute(writer, HTML.CLASS_ATTRIBUTE,
- HtmlUtil.concatClasses(helper.getRowClass(), helper.getColumnClass(),
"rf-ls-i"));
+ HtmlUtil.concatClasses(helper.getRowClass(), helper.getColumnClass(),
itemClass));
renderHandlers(context, sequence);
rendererUtils.encodeChildren(context, sequence);
writer.endElement(HTML.LI_ELEMENT);
@@ -122,7 +130,7 @@
}
rendererUtils.writeAttribute(writer, HTML.CLASS_ATTRIBUTE,
- HtmlUtil.concatClasses(helper.getRowClass(), helper.getColumnClass(),
"rf-ls-dt"));
+ HtmlUtil.concatClasses(helper.getRowClass(), helper.getColumnClass(),
"rf-lst-t rf-dlst-t"));
termFacet.encodeAll(context);
writer.endElement(HTML.DT_ELEMENT);
}
@@ -134,7 +142,7 @@
}
rendererUtils.writeAttribute(writer, HTML.CLASS_ATTRIBUTE,
- HtmlUtil.concatClasses(helper.getRowClass(), helper.getColumnClass(),
"rf-ls-dd"));
+ HtmlUtil.concatClasses(helper.getRowClass(), helper.getColumnClass(),
"rf-lst-i rf-dlst-i"));
renderHandlers(context, sequence);
rendererUtils.encodeChildren(context, sequence);
writer.endElement(HTML.DD_ELEMENT);
@@ -180,10 +188,40 @@
}
- private ItemsEncoder simpleItemsEncoder = new SimpleItemsEncoder();
+ private ItemsEncoder unorderedListItemsEncoder = new
SimpleItemsEncoder("rf-lst-i rf-ulst-i");
+ private ItemsEncoder orderedListItemsEncoder = new SimpleItemsEncoder("rf-lst-i
rf-olst-i");
+
private ItemsEncoder definitionItemsEncoder = new DefinitionItemsEncoder();
+ protected String getListClass(ListType type) {
+ switch (type) {
+ case ordered:
+ return "rf-lst rf-olst";
+ case unordered:
+ return "rf-lst rf-ulst";
+ case definitions:
+ return "rf-lst rf-dlst";
+
+ default:
+ throw new IllegalArgumentException(type.toString());
+ }
+ }
+
+ protected ItemsEncoder getItemsEncoderByType(ListType type) {
+ switch (type) {
+ case ordered:
+ return orderedListItemsEncoder;
+ case unordered:
+ return unorderedListItemsEncoder;
+ case definitions:
+ return definitionItemsEncoder;
+
+ default:
+ throw new IllegalArgumentException(type.toString());
+ }
+ }
+
protected ListType getType(UIComponent component) {
ListType type = ((AbstractList) component).getType();
if (type == null) {
@@ -194,17 +232,25 @@
return type;
}
- protected String getStyleClass(UIComponent component) {
+ protected String getStyleClass(UIComponent component, ListType listType) {
String styleClass = (String)
component.getAttributes().get(HTML.STYLE_CLASS_ATTR);
// TODO rf-* classes for different list types
- return HtmlUtil.concatClasses(styleClass, "rf-ls");
+ return HtmlUtil.concatClasses(styleClass, getListClass(listType));
}
- protected void encodeListItems(FacesContext context, UIComponent component, boolean
isSimpleList)
+ protected String getElementId(FacesContext facesContext, UIComponent component) {
+ if (rendererUtils.hasExplicitId(component)) {
+ return component.getClientId(facesContext);
+ }
+
+ return null;
+ }
+
+ protected void encodeListItems(FacesContext context, UIComponent component, ListType
listType)
throws IOException {
AbstractList list = (AbstractList) component;
try {
- ItemsEncoder itemsEncoder = isSimpleList ? simpleItemsEncoder :
definitionItemsEncoder;
+ ItemsEncoder itemsEncoder = getItemsEncoderByType(listType);
SequenceRendererHelper rendererHelper = new SequenceRendererHelper(list);
list.walk(context, itemsEncoder, rendererHelper);
Modified: root/ui/iteration/trunk/lists/ui/src/main/templates/list.template.xml
===================================================================
--- root/ui/iteration/trunk/lists/ui/src/main/templates/list.template.xml 2010-07-02
14:26:59 UTC (rev 17706)
+++ root/ui/iteration/trunk/lists/ui/src/main/templates/list.template.xml 2010-07-02
14:29:39 UTC (rev 17707)
@@ -78,21 +78,24 @@
<cc:implementation>
<cdk:object type="org.richfaces.component.ListType"
name="listType" value="#{getType(component)}" />
- <cdk:object name="styleClass"
value="#{getStyleClass(component)}" />
+
+ <cdk:object name="styleClass" value="#{getStyleClass(component,
listType)}" />
+ <cdk:object name="elementId"
value="#{getElementId(facesContext, component)}" />
+
<cdk:switch key="#{listType}">
<cdk:case values="ordered">
- <ol id="#{clientId}" class="#{styleClass}"
cdk:passThroughWithExclusions="type value">
- <cdk:call expression="encodeListItems(facesContext, component,
true)" />
+ <ol id="#{elementId}" class="#{styleClass}"
cdk:passThroughWithExclusions="type value">
+ <cdk:call expression="encodeListItems(facesContext, component,
listType)" />
</ol>
</cdk:case>
<cdk:case values="unordered">
- <ul id="#{clientId}" class="#{styleClass}"
cdk:passThroughWithExclusions="type value">
- <cdk:call expression="encodeListItems(facesContext, component,
true)" />
+ <ul id="#{elementId}" class="#{styleClass}"
cdk:passThroughWithExclusions="type value">
+ <cdk:call expression="encodeListItems(facesContext, component,
listType)" />
</ul>
</cdk:case>
<cdk:case values="definitions">
- <dl id="#{clientId}" class="#{styleClass}"
cdk:passThroughWithExclusions="type value">
- <cdk:call expression="encodeListItems(facesContext, component,
false)" />
+ <dl id="#{elementId}" class="#{styleClass}"
cdk:passThroughWithExclusions="type value">
+ <cdk:call expression="encodeListItems(facesContext, component,
listType)" />
</dl>
</cdk:case>
</cdk:switch>