Author: nbelaevski
Date: 2010-07-07 09:25:55 -0400 (Wed, 07 Jul 2010)
New Revision: 17759
Added:
root/ui/iteration/trunk/lists/ui/src/main/resources/
root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/
root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/resources/
root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/resources/org.richfaces/
root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/resources/org.richfaces/list.ecss
root/ui/iteration/trunk/lists/ui/src/test/
root/ui/iteration/trunk/lists/ui/src/test/java/
root/ui/iteration/trunk/lists/ui/src/test/java/org/
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/Data.java
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/DataBean.java
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/ListRendererTest.java
root/ui/iteration/trunk/lists/ui/src/test/resources/
root/ui/iteration/trunk/lists/ui/src/test/resources/org/
root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/
root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/
root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/faces-config.xml
root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/rendererTest.xhtml
Modified:
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java
Log:
https://jira.jboss.org/browse/RF-8853
https://jira.jboss.org/browse/RF-8855
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-07
12:55:57 UTC (rev 17758)
+++
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java 2010-07-07
13:25:55 UTC (rev 17759)
@@ -22,10 +22,12 @@
package org.richfaces.renderkit;
import java.io.IOException;
+import java.text.MessageFormat;
import java.util.Collections;
import java.util.Map;
import javax.faces.FacesException;
+import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -39,11 +41,13 @@
import org.richfaces.component.ListType;
import org.richfaces.component.UISequence;
import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.log.RichfacesLogger;
/**
* @author Nick Belaevski
- *
+ *
*/
+@ResourceDependency(library = "org.richfaces", name = "list.ecss")
public abstract class ListRendererBase extends Renderer {
private static final Map<String, ComponentAttribute> ROW_HANDLER_ATTRIBUTES =
Collections
@@ -63,9 +67,9 @@
new
ComponentAttribute(HTML.ONMOUSEOUT_ATTRIBUTE).setEventNames("rowmouseout").
setComponentAttributeName("onrowmouseout"),
new
ComponentAttribute(HTML.ONKEYPRESS_ATTRIBUTE).setEventNames("rowkeypress").
- setComponentAttributeName("onrowkeypress"),
+ setComponentAttributeName("onrowkeypress"),
new
ComponentAttribute(HTML.ONKEYDOWN_ATTRIBUTE).setEventNames("rowkeydown").
- setComponentAttributeName("onrowkeydown"),
+ setComponentAttributeName("onrowkeydown"),
new
ComponentAttribute(HTML.ONKEYUP_ATTRIBUTE).setEventNames("rowkeyup").
setComponentAttributeName("onrowkeyup")
));
@@ -74,12 +78,12 @@
/**
* @author Nick Belaevski
- *
+ *
*/
private class SimpleItemsEncoder extends ItemsEncoder {
-
+
private String itemClass;
-
+
public SimpleItemsEncoder(String itemClass) {
super();
this.itemClass = itemClass;
@@ -113,7 +117,7 @@
/**
* @author Nick Belaevski
- *
+ *
*/
private final class DefinitionItemsEncoder extends ItemsEncoder {
@Override
@@ -122,7 +126,7 @@
ResponseWriter writer = context.getResponseWriter();
UIComponent termFacet = sequence.getFacet(AbstractList.TERM);
- if (termFacet != null && termFacet.isRendered()) {
+ if (termFacet != null) {
writer.startElement(HTML.DT_ELEMENT, sequence);
if (rendererUtils.hasExplicitId(sequence)) {
@@ -142,7 +146,7 @@
}
rendererUtils.writeAttribute(writer, HTML.CLASS_ATTRIBUTE,
- HtmlUtil.concatClasses(helper.getRowClass(), helper.getColumnClass(),
"rf-lst-i rf-dlst-i"));
+ HtmlUtil.concatClasses(helper.getRowClass(), helper.getColumnClass(),
"rf-lst-d rf-dlst-d"));
renderHandlers(context, sequence);
rendererUtils.encodeChildren(context, sequence);
writer.endElement(HTML.DD_ELEMENT);
@@ -202,12 +206,12 @@
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:
@@ -216,17 +220,17 @@
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) {
- // TODO add component information
- throw new IllegalArgumentException("Type for rich:list is
required!");
+ String exceptionMessage = MessageFormat.format("Type for rich:list {0}
is required!", RichfacesLogger.getComponentPath(component));
+ throw new IllegalArgumentException(exceptionMessage);
}
return type;
@@ -234,7 +238,6 @@
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, getListClass(listType));
}
@@ -242,10 +245,10 @@
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;
Added:
root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/resources/org.richfaces/list.ecss
===================================================================
---
root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/resources/org.richfaces/list.ecss
(rev 0)
+++
root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/resources/org.richfaces/list.ecss 2010-07-07
13:25:55 UTC (rev 17759)
@@ -0,0 +1,5 @@
+.rf-lst-i, .rf-lst-t {
+ font-size: '#{richSkin.generalSizeFont}';
+ font-family: '#{richSkin.generalFamilyFont}';
+ color: '#{richSkin.generalTextColor}';
+}
\ No newline at end of file
Added: root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/Data.java
===================================================================
--- root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/Data.java
(rev 0)
+++
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/Data.java 2010-07-07
13:25:55 UTC (rev 17759)
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+/**
+ * @author nick
+ *
+ */
+public class Data {
+
+ private String term;
+
+ private String definition;
+
+ public Data(String term, String definition) {
+ super();
+ this.term = term;
+ this.definition = definition;
+ }
+
+ public String getDefinition() {
+ return definition;
+ }
+
+ public String getTerm() {
+ return term;
+ }
+}
Added:
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/DataBean.java
===================================================================
--- root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/DataBean.java
(rev 0)
+++
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/DataBean.java 2010-07-07
13:25:55 UTC (rev 17759)
@@ -0,0 +1,72 @@
+/*
+ * 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.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author nick
+ *
+ */
+public class DataBean {
+
+ private List<Data> list = new ArrayList<Data>();
+
+ public DataBean() {
+ list.add(new Data("RF-8282", "jQuery 1.4 AJAX requests broken if
using Richfaces"));
+ list.add(new Data("RF-6900", "scrollableDataTable: is getting
broken after vertical scrolling"));
+ list.add(new Data("RF-6917", "scrollableDataTable: scroll + sort +
F5 actions brake down the table at richfaces-demo"));
+ list.add(new Data("RF-6920", "scrollableDataTable: scroll +
rerender + F5 causes to enpty selection in FF3"));
+ list.add(new Data("RF-7695", "Error rendering extendedDataTable on
tab panel when switch type is ajax. in Google Chrome"));
+ list.add(new Data("RF-8072", "ExtendedDataTable : the table bugs
when the navigator is resized"));
+ list.add(new Data("RF-8143", "suggestionBox: submit the page when
you choose a list iten in Opera"));
+ list.add(new Data("RF-8490", "Editor can't be updated via ajax
in Chrome"));
+ list.add(new Data("RF-8521", "context menu doesn't show with
rightclickselection in FF OS X"));
+ list.add(new Data("RF-8536", "fileUpload does not always complete
in IE8"));
+ list.add(new Data("RF-2580", "orderingList, listShuttle, pickList:
buttons sometimes don't work if mouse cursor is above some special areas of the
button"));
+ list.add(new Data("RF-3220", "InplaceInput:
\"editEvent\" attribute with value \"ondblclick\" doesn't work on
Opera 9.25"));
+ list.add(new Data("RF-3398", "InplaceSelect: Broken under
Opera."));
+ list.add(new Data("RF-3504", "InputNumberSpinner: Doesn't work
after reRender in Opera."));
+ list.add(new Data("RF-3704", "InplaceInput component: part of
defaultLabel displays in the page (only for IE6)"));
+ list.add(new Data("RF-5285", "PickList: onlistchanged, onkeypress,
onblur events do not work in some browsers."));
+ list.add(new Data("RF-6926", "Tree: rightClickSelection attribute
does not work in Safari and Opera."));
+ list.add(new Data("RF-6967", "InputNumberSpinner:
disableBrowserAutoComplete works wrong"));
+ list.add(new Data("RF-7063", "Editor: Use Seam Text mode is work
incorrectly in safari and google chrome"));
+ list.add(new Data("RF-7100", "colorPicker: input and color box are
missaligned"));
+ list.add(new Data("RF-7162", "realworld/images/Opera: Unordered
list and Ordered list icons work incorrectly"));
+ list.add(new Data("RF-7169", "scrollableDataTable: first column
disappears after crolling"));
+ list.add(new Data("RF-7187", "InplaceInput attribute selectOnEdit
not worked in Safari/Chrome2"));
+ list.add(new Data("RF-7663", "scrollableDataTable: onRowDblClick
and onRowClick events is triggered once after sorting in safari"));
+ list.add(new Data("RF-7664", "colorPicker is opened up with
flat=\"true\" in ie 7"));
+ }
+
+ public List<Data> getList() {
+ return list;
+ }
+
+ public List<Data> getEmptyList() {
+ return Collections.emptyList();
+ }
+}
Added:
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/ListRendererTest.java
===================================================================
---
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/ListRendererTest.java
(rev 0)
+++
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/ListRendererTest.java 2010-07-07
13:25:55 UTC (rev 17759)
@@ -0,0 +1,158 @@
+/*
+ * 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.jboss.test.faces.htmlunit.HtmlUnitEnvironment;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * @author nick
+ *
+ */
+public class ListRendererTest {
+
+ private HtmlUnitEnvironment environment;
+
+ private DataBean testBean;
+
+ @Before
+ public void setUp() {
+ environment = new HtmlUnitEnvironment();
+
+ environment.withResource("/WEB-INF/faces-config.xml",
"org/richfaces/renderkit/faces-config.xml");
+ environment.withResource("/test.xhtml",
"org/richfaces/renderkit/rendererTest.xhtml");
+
+ environment.start();
+
+ testBean = new DataBean();
+ }
+
+ @After
+ public void tearDown() {
+ environment.release();
+ environment = null;
+
+ testBean = null;
+ }
+
+ @Test
+ public void testOrderedList() throws Exception {
+ HtmlPage page = environment.getPage("/test.jsf");
+ List<?> nodes = page.getByXPath("//*[@id = 'form:ol']");
+
+ assertEquals(1, nodes.size());
+ HtmlElement list = (HtmlElement) nodes.get(0);
+ assertEquals("ol", list.getNodeName());
+ assertEquals("rf-lst rf-olst",
list.getAttribute(HTML.CLASS_ATTRIBUTE));
+ verifySimpleListItems(list, "rf-lst-i rf-olst-i");
+ }
+
+ @Test
+ public void testUnorderedList() throws Exception {
+ HtmlPage page = environment.getPage("/test.jsf");
+ List<?> nodes = page.getByXPath("//*[@id = 'form:ul']");
+
+ assertEquals(1, nodes.size());
+ HtmlElement list = (HtmlElement) nodes.get(0);
+
+ assertEquals("ul", list.getNodeName());
+ assertEquals("rf-lst rf-ulst",
list.getAttribute(HTML.CLASS_ATTRIBUTE));
+ verifySimpleListItems((HtmlElement) list, "rf-lst-i rf-ulst-i");
+ }
+
+ @Test
+ public void testDefinitionsList() throws Exception {
+ HtmlPage page = environment.getPage("/test.jsf");
+ List<?> nodes = page.getByXPath("//*[@id = 'form:dl']");
+
+ assertEquals(1, nodes.size());
+ HtmlElement list = (HtmlElement) nodes.get(0);
+ assertEquals("dl", list.getNodeName());
+ verifyDefinitionsListItems(list);
+ }
+
+ @Test
+ public void testFakeItem() throws Exception {
+ HtmlPage page = environment.getPage("/test.jsf");
+ List<?> nodes = page.getByXPath("//*[@id =
'form:emptyList']");
+
+ assertEquals(1, nodes.size());
+ HtmlElement list = (HtmlElement) nodes.get(0);
+ assertEquals("ol", list.getNodeName());
+
+ HtmlElement fakeItem = (HtmlElement) list.getFirstByXPath("li");
+ assertNotNull(fakeItem);
+ assertEquals("display:none",
fakeItem.getAttribute("style"));
+ }
+
+ private void verifySimpleListItems(HtmlElement listElement, String styleClass) {
+ List<?> listItems = listElement.getByXPath("li");
+ assertEquals(testBean.getList().size(), listItems.size());
+ for (int i = 0; i < listItems.size(); i++) {
+ Data data = testBean.getList().get(i);
+
+ HtmlElement item = (HtmlElement) listItems.get(i);
+
+ assertEquals("li", item.getNodeName());
+ assertEquals(styleClass, item.getAttribute("class"));
+ assertEquals(data.getTerm(), item.asText());
+ }
+ }
+
+ private void verifyDefinitionsListItems(HtmlElement listElement) {
+ List<?> termItems = listElement.getByXPath("dt");
+ List<?> definitionItems = listElement.getByXPath("dd");
+
+ assertEquals(testBean.getList().size(), termItems.size());
+ assertEquals(testBean.getList().size(), definitionItems.size());
+
+ for (int i = 0; i < termItems.size(); i++) {
+ Data data = testBean.getList().get(i);
+
+ HtmlElement item = (HtmlElement) termItems.get(i);
+ assertEquals("dt", item.getNodeName());
+ assertEquals("rf-lst-t rf-dlst-t",
item.getAttribute("class"));
+ assertEquals(data.getTerm(), item.asText());
+ }
+
+ for (int i = 0; i < definitionItems.size(); i++) {
+ Data data = testBean.getList().get(i);
+
+ HtmlElement item = (HtmlElement) definitionItems.get(i);
+ assertEquals("dd", item.getNodeName());
+ assertEquals("rf-lst-d rf-dlst-d",
item.getAttribute("class"));
+ assertEquals(data.getDefinition(), item.asText());
+ }
+ }
+}
+
Added:
root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/faces-config.xml
===================================================================
---
root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/faces-config.xml
(rev 0)
+++
root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/faces-config.xml 2010-07-07
13:25:55 UTC (rev 17759)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+ <managed-bean>
+ <managed-bean-name>dataBean</managed-bean-name>
+ <managed-bean-class>org.richfaces.renderkit.DataBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
+</faces-config>
\ No newline at end of file
Added:
root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/rendererTest.xhtml
===================================================================
---
root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/rendererTest.xhtml
(rev 0)
+++
root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/rendererTest.xhtml 2010-07-07
13:25:55 UTC (rev 17759)
@@ -0,0 +1,33 @@
+<!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:lst="http://richfaces.org/lists">
+<f:view contentType="text/html" />
+
+<h:head>
+ <title>Richfaces List</title>
+</h:head>
+
+<h:body>
+ <h:form id="form">
+ <lst:list id="ol" var="item" value="#{dataBean.list}"
type="ordered">
+ #{item.term}
+ </lst:list>
+
+ <lst:list id="ul" var="item" value="#{dataBean.list}"
type="unordered">
+ #{item.term}
+ </lst:list>
+
+ <lst:list id="dl" var="item" value="#{dataBean.list}"
type="definitions">
+ <f:facet name="term">
+ #{item.term}
+ </f:facet>
+ #{item.definition}
+ </lst:list>
+
+ <lst:list id="emptyList" type="ordered" />
+ </h:form>
+</h:body>
+</html>