Author: nbelaevski
Date: 2010-07-01 15:24:55 -0400 (Thu, 01 Jul 2010)
New Revision: 17701
Added:
root/examples/iteration-demo/trunk/src/main/java/org/richfaces/demo/ListBean.java
root/examples/iteration-demo/trunk/src/main/webapp/list.xhtml
root/ui/iteration/trunk/lists/
root/ui/iteration/trunk/lists/api/
root/ui/iteration/trunk/lists/api/src/
root/ui/iteration/trunk/lists/api/src/main/
root/ui/iteration/trunk/lists/api/src/main/java/
root/ui/iteration/trunk/lists/api/src/main/java/org/
root/ui/iteration/trunk/lists/api/src/main/java/org/richfaces/
root/ui/iteration/trunk/lists/api/src/main/java/org/richfaces/component/
root/ui/iteration/trunk/lists/api/src/main/java/org/richfaces/component/ListType.java
root/ui/iteration/trunk/lists/pom.xml
root/ui/iteration/trunk/lists/ui/
root/ui/iteration/trunk/lists/ui/pom.xml
root/ui/iteration/trunk/lists/ui/src/
root/ui/iteration/trunk/lists/ui/src/main/
root/ui/iteration/trunk/lists/ui/src/main/java/
root/ui/iteration/trunk/lists/ui/src/main/java/org/
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/component/
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/component/AbstractList.java
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java
root/ui/iteration/trunk/lists/ui/src/main/templates/
root/ui/iteration/trunk/lists/ui/src/main/templates/list.template.xml
Modified:
root/examples/iteration-demo/trunk/src/main/webapp/index.xhtml
root/ui/iteration/trunk/dist/richfaces-ui-iteration-api/pom.xml
root/ui/iteration/trunk/dist/richfaces-ui-iteration-ui/pom.xml
root/ui/iteration/trunk/pom.xml
Log:
https://jira.jboss.org/browse/RF-8753
Added: root/examples/iteration-demo/trunk/src/main/java/org/richfaces/demo/ListBean.java
===================================================================
--- root/examples/iteration-demo/trunk/src/main/java/org/richfaces/demo/ListBean.java
(rev 0)
+++
root/examples/iteration-demo/trunk/src/main/java/org/richfaces/demo/ListBean.java 2010-07-01
19:24:55 UTC (rev 17701)
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+package org.richfaces.demo;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+
+import org.richfaces.component.ListType;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@ManagedBean
+@SessionScoped
+public class ListBean {
+
+ private String listType = ListType.unordered.name();
+
+ public String getListType() {
+ return listType;
+ }
+
+ public void setListType(String listType) {
+ this.listType = listType;
+ }
+}
Modified: root/examples/iteration-demo/trunk/src/main/webapp/index.xhtml
===================================================================
--- root/examples/iteration-demo/trunk/src/main/webapp/index.xhtml 2010-07-01 19:21:53 UTC
(rev 17700)
+++ root/examples/iteration-demo/trunk/src/main/webapp/index.xhtml 2010-07-01 19:24:55 UTC
(rev 17701)
@@ -11,6 +11,7 @@
<li><h:link
outcome="dataTable">rich:DataTable</h:link></li>
<li><h:link
outcome="extendedtable">rich:extendedDataTable</h:link></li>
<li><h:link outcome="filteringAndSorting">filtering and sorting
feature</h:link></li>
+ <li><h:link outcome="list">rich:list</h:link></li>
</ul>
<h:form>
Added: root/examples/iteration-demo/trunk/src/main/webapp/list.xhtml
===================================================================
--- root/examples/iteration-demo/trunk/src/main/webapp/list.xhtml
(rev 0)
+++ root/examples/iteration-demo/trunk/src/main/webapp/list.xhtml 2010-07-01 19:24:55 UTC
(rev 17701)
@@ -0,0 +1,32 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:it="http://richfaces.org/iteration">
+<f:view contentType="text/html" />
+
+<h:head>
+ <title>Richfaces List</title>
+</h:head>
+
+<h:body>
+ <h:form>
+ <h:selectOneListbox value="#{listBean.listType}"
onchange="submit()">
+ <f:selectItem itemValue="ordered" />
+ <f:selectItem itemValue="unordered" />
+ <f:selectItem itemValue="definitions" />
+ </h:selectOneListbox>
+ </h:form>
+
+ <h:form id="form1">
+ <it:list id="list" var="item"
value="#{dataBean.employeeList}" rows="20"
type="#{listBean.listType}">
+ <f:facet name="term">
+ #{item.EMail}
+ </f:facet>
+
+ #{item.name}
+ </it:list>
+ </h:form>
+</h:body>
+</html>
Modified: root/ui/iteration/trunk/dist/richfaces-ui-iteration-api/pom.xml
===================================================================
--- root/ui/iteration/trunk/dist/richfaces-ui-iteration-api/pom.xml 2010-07-01 19:21:53
UTC (rev 17700)
+++ root/ui/iteration/trunk/dist/richfaces-ui-iteration-api/pom.xml 2010-07-01 19:24:55
UTC (rev 17701)
@@ -63,6 +63,11 @@
<artifactId>tables-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${assembly.projects.group}</groupId>
+ <artifactId>lists-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- artifacts for javadoc generation -->
<dependency>
Modified: root/ui/iteration/trunk/dist/richfaces-ui-iteration-ui/pom.xml
===================================================================
--- root/ui/iteration/trunk/dist/richfaces-ui-iteration-ui/pom.xml 2010-07-01 19:21:53 UTC
(rev 17700)
+++ root/ui/iteration/trunk/dist/richfaces-ui-iteration-ui/pom.xml 2010-07-01 19:24:55 UTC
(rev 17701)
@@ -69,6 +69,11 @@
<artifactId>tables-ui</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${assembly.projects.group}</groupId>
+ <artifactId>lists-ui</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- artifacts for javadoc generation -->
<dependency>
Added:
root/ui/iteration/trunk/lists/api/src/main/java/org/richfaces/component/ListType.java
===================================================================
--- root/ui/iteration/trunk/lists/api/src/main/java/org/richfaces/component/ListType.java
(rev 0)
+++
root/ui/iteration/trunk/lists/api/src/main/java/org/richfaces/component/ListType.java 2010-07-01
19:24:55 UTC (rev 17701)
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+package org.richfaces.component;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public enum ListType {
+
+ ordered, unordered, definitions
+
+}
Added: root/ui/iteration/trunk/lists/pom.xml
===================================================================
--- root/ui/iteration/trunk/lists/pom.xml (rev 0)
+++ root/ui/iteration/trunk/lists/pom.xml 2010-07-01 19:24:55 UTC (rev 17701)
@@ -0,0 +1,48 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.richfaces.ui.iteration</groupId>
+ <artifactId>richfaces-ui-iteration-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.richfaces.ui.iteration</groupId>
+ <artifactId>lists-aggregator</artifactId>
+ <packaging>pom</packaging>
+ <name>Richfaces UI Components: Lists Aggregator</name>
+
+ <modules>
+ <module>api</module>
+ <module>ui</module>
+ </modules>
+
+ <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/pom.xml
===================================================================
--- root/ui/iteration/trunk/lists/ui/pom.xml (rev 0)
+++ root/ui/iteration/trunk/lists/ui/pom.xml 2010-07-01 19:24:55 UTC (rev 17701)
@@ -0,0 +1,136 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.richfaces.ui.iteration</groupId>
+ <artifactId>lists-aggregator</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.richfaces.ui.iteration</groupId>
+ <artifactId>lists-ui</artifactId>
+ <packaging>jar</packaging>
+ <name>Richfaces UI Components: Lists UI</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <!-- runtime -->
+ <dependency>
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-api</artifactId>
+ </dependency>
+ <dependency>
+ <!-- todo remove this dependency or move to test scope -->
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.richfaces.ui.iteration</groupId>
+ <artifactId>lists-api</artifactId>
+ <version>${project.version}</version>
+ </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>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </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/component/AbstractList.java
===================================================================
---
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/component/AbstractList.java
(rev 0)
+++
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/component/AbstractList.java 2010-07-01
19:24:55 UTC (rev 17701)
@@ -0,0 +1,159 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import java.util.Iterator;
+
+import javax.faces.component.UIComponent;
+
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.Facet;
+import org.richfaces.cdk.annotations.JsfComponent;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Maps;
+
+/**
+ * JSF component class
+ *
+ */
+@JsfComponent(type = "org.richfaces.List", family =
"org.richfaces.List", facets = @Facet(name = AbstractList.TERM))
+public abstract class AbstractList extends UISequence {
+
+ public static final String TERM = "term";
+
+ private static final Predicate<String> TERM_PREDICATE = new
Predicate<String>() {
+
+ public boolean apply(String input) {
+ return TERM.equals(input);
+ }
+ };
+
+ private static final Predicate<String> NON_TERM_PREDICATE =
Predicates.not(TERM_PREDICATE);
+
+ private Iterator<UIComponent> getFacetsIterator(Predicate<? super String>
namePredicate) {
+ if (getFacetCount() > 0) {
+ return Maps.filterKeys(getFacets(), namePredicate).values().iterator();
+ }
+
+ return Iterators.emptyIterator();
+ }
+
+ protected Iterator<UIComponent> dataChildren() {
+ return Iterators.concat(getChildren().iterator(),
getFacetsIterator(TERM_PREDICATE));
+ }
+
+ protected Iterator<UIComponent> fixedChildren() {
+ return getFacetsIterator(NON_TERM_PREDICATE);
+ }
+
+ @Attribute(required = true)
+ public abstract ListType getType();
+
+ public UIComponent getTerm() {
+ return getFacet(TERM);
+ }
+
+ @Attribute(events = @EventName("click"))
+ public abstract String getOnclick();
+
+ @Attribute(events = @EventName("dblclick"))
+ public abstract String getOndblclick();
+
+ @Attribute(events = @EventName("mousedown"))
+ public abstract String getOnmousedown();
+
+ @Attribute(events = @EventName("mouseup"))
+ public abstract String getOnmouseup();
+
+ @Attribute(events = @EventName("mouseover"))
+ public abstract String getOnmouseover();
+
+ @Attribute(events = @EventName("mousemove"))
+ public abstract String getOnmousemove();
+
+ @Attribute(events = @EventName("mouseout"))
+ public abstract String getOnmouseout();
+
+ @Attribute(events = @EventName("keypress"))
+ public abstract String getOnkeypress();
+
+ @Attribute(events = @EventName("keydown"))
+ public abstract String getOnkeydown();
+
+ @Attribute(events = @EventName("keyup"))
+ public abstract String getOnkeyup();
+
+ @Attribute(events = @EventName("rowclick"))
+ public abstract String getOnrowclick();
+
+ @Attribute(events = @EventName("rowdblclick"))
+ public abstract String getOnrowdblclick();
+
+ @Attribute(events = @EventName("rowmousedown"))
+ public abstract String getOnrowmousedown();
+
+ @Attribute(events = @EventName("rowmouseup"))
+ public abstract String getOnrowmouseup();
+
+ @Attribute(events = @EventName("rowmouseover"))
+ public abstract String getOnrowmouseover();
+
+ @Attribute(events = @EventName("rowmousemove"))
+ public abstract String getOnrowmousemove();
+
+ @Attribute(events = @EventName("rowmouseout"))
+ public abstract String getOnrowmouseout();
+
+ @Attribute(events = @EventName("rowkeypress"))
+ public abstract String getOnrowkeypress();
+
+ @Attribute(events = @EventName("rowkeydown"))
+ public abstract String getOnrowkeydown();
+
+ @Attribute(events = @EventName("rowkeyup"))
+ public abstract String getOnrowkeyup();
+
+ @Attribute
+ public abstract String getStyle();
+
+ @Attribute
+ public abstract String getStyleClass();
+
+ @Attribute
+ public abstract String getTitle();
+
+ @Attribute
+ public abstract String getDir();
+
+ @Attribute
+ public abstract String getLang();
+
+ @Attribute
+ public abstract String getRowClasses();
+
+ @Attribute
+ public abstract String getRowClass();
+}
Added:
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
(rev 0)
+++
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java 2010-07-01
19:24:55 UTC (rev 17701)
@@ -0,0 +1,223 @@
+/*
+ * 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.
+ */
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+
+import org.ajax4jsf.model.DataVisitResult;
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.AbstractList;
+import org.richfaces.component.ListType;
+import org.richfaces.component.UISequence;
+import org.richfaces.component.util.HtmlUtil;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class ListRendererBase extends Renderer {
+
+ private static final Map<String, ComponentAttribute> ROW_HANDLER_ATTRIBUTES =
Collections
+ .unmodifiableMap(ComponentAttribute.createMap(
+ new
ComponentAttribute(HTML.ONCLICK_ATTRIBUTE).setEventNames("rowclick").
+ setComponentAttributeName("onrowclick"),
+ new
ComponentAttribute(HTML.ONDBLCLICK_ATTRIBUTE).setEventNames("rowdblclick").
+ setComponentAttributeName("onrowdblclick"),
+ new
ComponentAttribute(HTML.ONMOUSEDOWN_ATTRIBUTE).setEventNames("rowmousedown").
+ setComponentAttributeName("onrowmousedown"),
+ new
ComponentAttribute(HTML.ONMOUSEUP_ATTRIBUTE).setEventNames("rowmouseup").
+ setComponentAttributeName("onrowmouseup"),
+ new
ComponentAttribute(HTML.ONMOUSEOVER_ATTRIBUTE).setEventNames("rowmouseover").
+ setComponentAttributeName("onrowmouseover"),
+ new
ComponentAttribute(HTML.ONMOUSEMOVE_ATTRIBUTE).setEventNames("rowmousemove").
+ setComponentAttributeName("onrowmousemove"),
+ new
ComponentAttribute(HTML.ONMOUSEOUT_ATTRIBUTE).setEventNames("rowmouseout").
+ setComponentAttributeName("onrowmouseout"),
+ new
ComponentAttribute(HTML.ONKEYPRESS_ATTRIBUTE).setEventNames("rowkeypress").
+ setComponentAttributeName("onrowkeypress"),
+ new
ComponentAttribute(HTML.ONKEYDOWN_ATTRIBUTE).setEventNames("rowkeydown").
+ setComponentAttributeName("onrowkeydown"),
+ new
ComponentAttribute(HTML.ONKEYUP_ATTRIBUTE).setEventNames("rowkeyup").
+ setComponentAttributeName("onrowkeyup")
+ ));
+
+ private RendererUtils rendererUtils = RendererUtils.getInstance();
+
+ /**
+ * @author Nick Belaevski
+ *
+ */
+ private final class SimpleItemsEncoder extends ItemsEncoder {
+ @Override
+ protected void encodeRow(FacesContext context, UISequence sequence,
SequenceRendererHelper helper)
+ throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+
+ writer.startElement(HTML.LI_ELEMENT, sequence);
+
+ if (rendererUtils.hasExplicitId(sequence)) {
+ rendererUtils.writeAttribute(writer, HTML.ID_ATTRIBUTE,
sequence.getClientId(context));
+ }
+
+ rendererUtils.writeAttribute(writer, HTML.CLASS_ATTRIBUTE,
+ HtmlUtil.concatClasses(helper.getRowClass(), helper.getColumnClass(),
"rf-ls-i"));
+ renderHandlers(context, sequence);
+ rendererUtils.encodeChildren(context, sequence);
+ writer.endElement(HTML.LI_ELEMENT);
+ }
+
+ public void encodeFakeItem(FacesContext context, UIComponent component) throws
IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(HTML.LI_ELEMENT, component);
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, "display:none", null);
+ writer.endElement(HTML.LI_ELEMENT);
+ }
+ }
+
+ /**
+ * @author Nick Belaevski
+ *
+ */
+ private final class DefinitionItemsEncoder extends ItemsEncoder {
+ @Override
+ protected void encodeRow(FacesContext context, UISequence sequence,
SequenceRendererHelper helper)
+ throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+
+ UIComponent termFacet = sequence.getFacet(AbstractList.TERM);
+ if (termFacet != null && termFacet.isRendered()) {
+ writer.startElement(HTML.DT_ELEMENT, sequence);
+
+ if (rendererUtils.hasExplicitId(sequence)) {
+ rendererUtils.writeAttribute(writer, HTML.ID_ATTRIBUTE,
sequence.getClientId(context) + ".dt");
+ }
+
+ rendererUtils.writeAttribute(writer, HTML.CLASS_ATTRIBUTE,
+ HtmlUtil.concatClasses(helper.getRowClass(), helper.getColumnClass(),
"rf-ls-dt"));
+ termFacet.encodeAll(context);
+ writer.endElement(HTML.DT_ELEMENT);
+ }
+
+ writer.startElement(HTML.DD_ELEMENT, sequence);
+
+ if (rendererUtils.hasExplicitId(sequence)) {
+ rendererUtils.writeAttribute(writer, HTML.ID_ATTRIBUTE,
sequence.getClientId(context));
+ }
+
+ rendererUtils.writeAttribute(writer, HTML.CLASS_ATTRIBUTE,
+ HtmlUtil.concatClasses(helper.getRowClass(), helper.getColumnClass(),
"rf-ls-dd"));
+ renderHandlers(context, sequence);
+ rendererUtils.encodeChildren(context, sequence);
+ writer.endElement(HTML.DD_ELEMENT);
+ }
+
+ public void encodeFakeItem(FacesContext context, UIComponent component) throws
IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(HTML.DD_ELEMENT, component);
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, "display:none", null);
+ writer.endElement(HTML.DD_ELEMENT);
+ }
+ }
+
+ private abstract class ItemsEncoder implements DataVisitor {
+
+ protected void renderHandlers(FacesContext context, UISequence sequence) throws
IOException {
+ RenderKitUtils.renderPassThroughAttributesOptimized(context, sequence,
ROW_HANDLER_ATTRIBUTES);
+ }
+
+ protected abstract void encodeRow(FacesContext context, UISequence sequence,
SequenceRendererHelper helper)
+ throws IOException;
+
+ public DataVisitResult process(FacesContext context, Object rowKey, Object
argument) {
+ SequenceRendererHelper helper = (SequenceRendererHelper) argument;
+ UISequence sequence = helper.getSequence();
+ sequence.setRowKey(context, rowKey);
+ if (sequence.isRowAvailable()) {
+ helper.nextRow();
+
+ try {
+ encodeRow(context, sequence, helper);
+ } catch (IOException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
+
+ return DataVisitResult.CONTINUE;
+ } else {
+ return DataVisitResult.STOP;
+ }
+ }
+
+ public abstract void encodeFakeItem(FacesContext context, UIComponent component)
throws IOException;
+
+ }
+
+ private ItemsEncoder simpleItemsEncoder = new SimpleItemsEncoder();
+
+ private ItemsEncoder definitionItemsEncoder = new DefinitionItemsEncoder();
+
+ protected ListType getType(UIComponent component) {
+ ListType type = ((AbstractList) component).getType();
+ if (type == null) {
+ // TODO add component information
+ throw new IllegalArgumentException("Type for rich:list is
required!");
+ }
+
+ return type;
+ }
+
+ protected String getStyleClass(UIComponent component) {
+ String styleClass = (String)
component.getAttributes().get(HTML.STYLE_CLASS_ATTR);
+ // TODO rf-* classes for different list types
+ return HtmlUtil.concatClasses(styleClass, "rf-ls");
+ }
+
+ protected void encodeListItems(FacesContext context, UIComponent component, boolean
isSimpleList)
+ throws IOException {
+ AbstractList list = (AbstractList) component;
+ try {
+ ItemsEncoder itemsEncoder = isSimpleList ? simpleItemsEncoder :
definitionItemsEncoder;
+ SequenceRendererHelper rendererHelper = new SequenceRendererHelper(list);
+ list.walk(context, itemsEncoder, rendererHelper);
+
+ if (!rendererHelper.hasWalkedOverRows()) {
+ itemsEncoder.encodeFakeItem(context, component);
+ }
+ } catch (FacesException e) {
+ // TODO nick - review
+ if (e.getCause() instanceof IOException) {
+ throw (IOException) e.getCause();
+ } else {
+ throw e;
+ }
+ }
+ }
+}
Added: root/ui/iteration/trunk/lists/ui/src/main/templates/list.template.xml
===================================================================
--- root/ui/iteration/trunk/lists/ui/src/main/templates/list.template.xml
(rev 0)
+++ root/ui/iteration/trunk/lists/ui/src/main/templates/list.template.xml 2010-07-01
19:24:55 UTC (rev 17701)
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<cdk:root
xmlns="http://richfaces.org/cdk/xhtml-el"
xmlns:cdk="http://richfaces.org/cdk/core"
+
xmlns:c="http://richfaces.org/cdk/jstl/core"
xmlns:cc="http://richfaces.org/cdk/jsf/composite"
+
xmlns:javaee="http://java.sun.com/xml/ns/javaee">
+
+ <cc:interface>
+ <cdk:class>org.richfaces.renderkit.html.ListRenderer</cdk:class>
+
<cdk:superclass>org.richfaces.renderkit.ListRendererBase</cdk:superclass>
+ <cdk:component-family>org.richfaces.List</cdk:component-family>
+ <cdk:renderer-type>org.richfaces.ListRenderer
+ </cdk:renderer-type>
+ <cdk:renders-children>true</cdk:renders-children>
+
+ <!--
+ <cc:attribute name="onclick" type="java.lang.String">
+ <cc:clientBehavior event="click" />
+ </cc:attribute>
+ <cc:attribute name="ondblclick"
type="java.lang.String">
+ <cc:clientBehavior event="dblclick" />
+ </cc:attribute>
+ <cc:attribute name="onmousedown"
type="java.lang.String">
+ <cc:clientBehavior event="mousedown" />
+ </cc:attribute>
+ <cc:attribute name="onmouseup"
type="java.lang.String">
+ <cc:clientBehavior event="mouseup" />
+ </cc:attribute>
+ <cc:attribute name="onmouseover"
type="java.lang.String">
+ <cc:clientBehavior event="mouseover" />
+ </cc:attribute>
+ <cc:attribute name="onmousemove"
type="java.lang.String">
+ <cc:clientBehavior event="mousemove" />
+ </cc:attribute>
+ <cc:attribute name="onmouseout"
type="java.lang.String">
+ <cc:clientBehavior event="mouseout" />
+ </cc:attribute>
+ <cc:attribute name="onkeypress"
type="java.lang.String">
+ <cc:clientBehavior event="keypress" />
+ </cc:attribute>
+ <cc:attribute name="onkeydown"
type="java.lang.String">
+ <cc:clientBehavior event="keydown" />
+ </cc:attribute>
+ <cc:attribute name="onkeyup" type="java.lang.String">
+ <cc:clientBehavior event="keyup" />
+ </cc:attribute>
+ <cc:attribute name="onrowclick"
type="java.lang.String">
+ <cc:clientBehavior event="rowclick" />
+ </cc:attribute>
+ <cc:attribute name="onrowdblclick"
type="java.lang.String">
+ <cc:clientBehavior event="rowdblclick" />
+ </cc:attribute>
+ <cc:attribute name="onrowmousedown"
type="java.lang.String">
+ <cc:clientBehavior event="rowmousedown" />
+ </cc:attribute>
+ <cc:attribute name="onrowmouseup"
type="java.lang.String">
+ <cc:clientBehavior event="rowmouseup" />
+ </cc:attribute>
+ <cc:attribute name="onrowmouseover"
type="java.lang.String">
+ <cc:clientBehavior event="rowmouseover" />
+ </cc:attribute>
+ <cc:attribute name="onrowmousemove"
type="java.lang.String">
+ <cc:clientBehavior event="rowmousemove" />
+ </cc:attribute>
+ <cc:attribute name="onrowmouseout"
type="java.lang.String">
+ <cc:clientBehavior event="rowmouseout" />
+ </cc:attribute>
+ <cc:attribute name="onrowkeypress"
type="java.lang.String">
+ <cc:clientBehavior event="rowkeypress" />
+ </cc:attribute>
+ <cc:attribute name="onrowkeydown"
type="java.lang.String">
+ <cc:clientBehavior event="rowkeydown" />
+ </cc:attribute>
+ <cc:attribute name="onrowkeyup"
type="java.lang.String">
+ <cc:clientBehavior event="rowkeyup" />
+ </cc:attribute>
+ -->
+ </cc:interface>
+
+ <cc:implementation>
+ <cdk:object type="org.richfaces.component.ListType"
name="listType" value="#{getType(component)}" />
+ <cdk:object name="styleClass"
value="#{getStyleClass(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>
+ </cdk:case>
+ <cdk:case values="unordered">
+ <ul id="#{clientId}" class="#{styleClass}"
cdk:passThroughWithExclusions="type value">
+ <cdk:call expression="encodeListItems(facesContext, component,
true)" />
+ </ul>
+ </cdk:case>
+ <cdk:case values="definitions">
+ <dl id="#{clientId}" class="#{styleClass}"
cdk:passThroughWithExclusions="type value">
+ <cdk:call expression="encodeListItems(facesContext, component,
false)" />
+ </dl>
+ </cdk:case>
+ </cdk:switch>
+ </cc:implementation>
+
+</cdk:root>
Modified: root/ui/iteration/trunk/pom.xml
===================================================================
--- root/ui/iteration/trunk/pom.xml 2010-07-01 19:21:53 UTC (rev 17700)
+++ root/ui/iteration/trunk/pom.xml 2010-07-01 19:24:55 UTC (rev 17701)
@@ -39,6 +39,7 @@
<module>parent</module>
<module>tables</module>
<module>datascroller</module>
+ <module>lists</module>
<module>dist</module>
</modules>