JBoss Rich Faces SVN: r20414 - in modules/tests/metamer/trunk: ftest-source/src/main/java/org/richfaces/tests/metamer/ftest and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-12-06 12:55:11 -0500 (Mon, 06 Dec 2010)
New Revision: 20414
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/templates/header.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
Log:
added output of the view locale to the page and method AbstractMetamerTest.getLocale() for obtaining locale from tests
Modified: modules/tests/metamer/trunk/application/src/main/webapp/templates/header.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/templates/header.xhtml 2010-12-06 17:54:03 UTC (rev 20413)
+++ modules/tests/metamer/trunk/application/src/main/webapp/templates/header.xhtml 2010-12-06 17:55:11 UTC (rev 20414)
@@ -62,7 +62,10 @@
</f:facet>
</a4j:status>
</a4j:outputPanel>
-
+
+ <h:outputLabel value="Locale" />
+ <h:outputText id="locale" value="#{facesContext.viewRoot.locale}" />
+
<h:outputText id="showUiDebugLabel" value="Show ui:debug" />
<h:outputText id="showUiDebug" value="Ctrl+Shift+L" />
<ui:debug hotkey="L" />
@@ -136,6 +139,8 @@
</h:panelGrid>
+
+
</ui:composition>
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-12-06 17:54:03 UTC (rev 20413)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-12-06 17:55:11 UTC (rev 20414)
@@ -31,9 +31,11 @@
import static org.testng.Assert.assertTrue;
import java.net.URL;
+import java.util.Locale;
import javax.faces.event.PhaseId;
+import org.apache.commons.lang.LocaleUtils;
import org.jboss.test.selenium.AbstractTestCase;
import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.encapsulated.JavaScript;
@@ -176,6 +178,15 @@
waitGui.failWith("Attribute on" + attributeName + " does not work correctly").until(
new EventFiredCondition(event));
}
+
+ /**
+ * Returns the locale of the tested page
+ * @return the locale of the tested page
+ */
+ public Locale getLocale() {
+ String localeString = selenium.getText(id("locale"));
+ return LocaleUtils.toLocale(localeString);
+ }
/**
* A helper method for testing attribute "style". It sets "background-color: yellow; font-size: 1.5em;" to the input
14 years, 1 month
JBoss Rich Faces SVN: r20413 - modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-12-06 12:54:03 -0500 (Mon, 06 Dec 2010)
New Revision: 20413
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/Employee.java
Log:
overriden Employee.toString() for better debug output
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/Employee.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/Employee.java 2010-12-06 17:53:17 UTC (rev 20412)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/Employee.java 2010-12-06 17:54:03 UTC (rev 20413)
@@ -186,4 +186,8 @@
return hash;
}
+ @Override
+ public String toString() {
+ return "Employee [name=" + name + ", sex=" + sex + ", title=" + title + ", numberOfKids=" + numberOfKids + "]";
+ }
}
\ No newline at end of file
14 years, 1 month
JBoss Rich Faces SVN: r20412 - in modules/tests/metamer/trunk: application/src/main/webapp/components/richDataTable and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-12-06 12:53:17 -0500 (Mon, 06 Dec 2010)
New Revision: 20412
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/AbstractDataTableTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTable.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacetsTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFilteringTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableScrollerTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSortingTest.java
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/Model.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/filtering.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAutocomplete/TestAutocompleteByKeys.java
Log:
Added abstract implementation of data table tests as stub for rich:dataTable and rich:extendedDataTable tests (RFPL-912, RFPL-918)
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/Model.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/Model.java 2010-12-06 17:51:19 UTC (rev 20411)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/Model.java 2010-12-06 17:53:17 UTC (rev 20412)
@@ -29,7 +29,6 @@
import java.util.List;
import java.util.Set;
-import javax.faces.FacesException;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.model.SelectItem;
@@ -69,11 +68,7 @@
*/
public synchronized List<Capital> getCapitals() {
if (capitalsList == null) {
- try {
- capitalsList = unmarshallCapitals();
- } catch (JAXBException e) {
- throw new FacesException(e.getMessage(), e);
- }
+ capitalsList = unmarshallCapitals();
}
return capitalsList;
@@ -86,11 +81,7 @@
*/
public synchronized List<Employee> getEmployees() {
if (employeesList == null) {
- try {
- employeesList = unmarshallEmployees();
- } catch (JAXBException e) {
- throw new FacesException(e.getMessage(), e);
- }
+ employeesList = unmarshallEmployees();
}
return employeesList;
@@ -103,11 +94,7 @@
*/
public synchronized List<CompactDiscXmlDescriptor> getCompactDiscs() {
if (compactDiscList == null) {
- try {
- compactDiscList = unmarshallCompactDiscs();
- } catch (JAXBException e) {
- throw new FacesException(e.getMessage(), e);
- }
+ compactDiscList = unmarshallCompactDiscs();
}
return compactDiscList;
@@ -120,16 +107,28 @@
* @throws JAXBException
* if any unexpected errors occurs during unmarshalling
*/
- public static final List<Capital> unmarshallCapitals() throws JAXBException {
- return unmarshall(CapitalsHolder.class, "org/richfaces/tests/metamer/model/capitals.xml");
+ public static final List<Capital> unmarshallCapitals() {
+ try {
+ return unmarshall(CapitalsHolder.class, "org/richfaces/tests/metamer/model/capitals.xml");
+ } catch (JAXBException e) {
+ throw new IllegalStateException(e);
+ }
}
- public static final List<Employee> unmarshallEmployees() throws JAXBException {
- return unmarshall(EmployeesHolder.class, "org/richfaces/tests/metamer/model/employees.xml");
+ public static final List<Employee> unmarshallEmployees() {
+ try {
+ return unmarshall(EmployeesHolder.class, "org/richfaces/tests/metamer/model/employees.xml");
+ } catch (JAXBException e) {
+ throw new IllegalStateException(e);
+ }
}
- public static final List<CompactDiscXmlDescriptor> unmarshallCompactDiscs() throws JAXBException {
- return unmarshall(CompactDiscsHolder.class, "org/richfaces/tests/metamer/model/compact-discs.xml");
+ public static final List<CompactDiscXmlDescriptor> unmarshallCompactDiscs() {
+ try {
+ return unmarshall(CompactDiscsHolder.class, "org/richfaces/tests/metamer/model/compact-discs.xml");
+ } catch (JAXBException e) {
+ throw new IllegalStateException(e);
+ }
}
@SuppressWarnings("unchecked")
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/filtering.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/filtering.xhtml 2010-12-06 17:51:19 UTC (rev 20411)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/filtering.xhtml 2010-12-06 17:53:17 UTC (rev 20412)
@@ -81,7 +81,7 @@
</h:panelGroup>
</f:facet>
- <h:graphicImage library="images" name="#{record.sex == 'MALE' ? 'male.png' : 'female.png'}" />
+ <h:graphicImage library="images" name="#{record.sex == 'MALE' ? 'male.png' : 'female.png'}" alt="record.sex" />
<f:facet name="footer">
<h:outputText id="columnFooterSex" value="Sex" />
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/AbstractDataTableTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/AbstractDataTableTest.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/AbstractDataTableTest.java 2010-12-06 17:53:17 UTC (rev 20412)
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * 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.tests.metamer.ftest.abstractions;
+
+import static org.jboss.test.selenium.locator.Attribute.ALT;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+
+import java.util.List;
+
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.metamer.bean.Model;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.model.AssertingDataScroller;
+import org.richfaces.tests.metamer.ftest.model.DataScroller;
+import org.richfaces.tests.metamer.model.Capital;
+import org.richfaces.tests.metamer.model.Employee;
+import org.richfaces.tests.metamer.model.Employee.Sex;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public abstract class AbstractDataTableTest extends AbstractMetamerTest {
+ protected static final List<Capital> CAPITALS = Model.unmarshallCapitals();
+ protected static final List<Employee> EMPLOYEES = Model.unmarshallEmployees();
+ protected static final int ELEMENTS_TOTAL = 50;
+
+ protected static final int COLUMN_STATE = 1;
+ protected static final int COLUMN_CAPITAL = 2;
+
+ protected static final int COLUMN_SEX = 1;
+ protected static final int COLUMN_NAME = 2;
+ protected static final int COLUMN_TITLE = 3;
+ protected static final int COLUMN_NUMBER_OF_KIDS1 = 4;
+ protected static final int COLUMN_NUMBER_OF_KIDS2 = 5;
+
+ protected static final Integer[] COUNTS = new Integer[] { null, 1, 3, 11, ELEMENTS_TOTAL / 2, ELEMENTS_TOTAL - 1,
+ ELEMENTS_TOTAL, ELEMENTS_TOTAL + 1 };
+
+ protected DataTable model;
+ protected EmployeeTableModel employees;
+ protected DataTableAttributes attributes;
+ protected DataTableFacets facets;
+
+ protected DataScroller dataScroller1 = new AssertingDataScroller("outside-table", pjq("span.rf-ds[id$=scroller1]"));
+ protected DataScroller dataScroller2 = new AssertingDataScroller("inside-table-footer",
+ pjq("span.rf-ds[id$=scroller2]"));
+
+ public class EmployeeTableModel {
+ public Sex getSex(int row) {
+ JQueryLocator element = model.getElement(COLUMN_SEX, row).getDescendant(jq("img"));
+ String sex = selenium.getAttribute(element.getAttribute(ALT));
+ return Sex.valueOf(sex.toUpperCase());
+ }
+
+ public String getName(int row) {
+ return selenium.getText(model.getElement(COLUMN_NAME, row));
+ }
+
+ public String getTitle(int row) {
+ return selenium.getText(model.getElement(COLUMN_TITLE, row));
+ }
+
+ public int getNumberOfKids(int row) {
+ return Integer.valueOf(selenium.getText(model.getElement(COLUMN_NUMBER_OF_KIDS1, row)));
+ }
+ }
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTable.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTable.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTable.java 2010-12-06 17:53:17 UTC (rev 20412)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * 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.tests.metamer.ftest.abstractions;
+
+import org.jboss.test.selenium.locator.JQueryLocator;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public interface DataTable {
+ int getPages();
+
+ int getCurrentPage();
+
+ int getRows();
+
+ int getColumns();
+
+ boolean isVisible();
+
+ boolean isNoData();
+
+ JQueryLocator getNoData();
+
+ JQueryLocator getElement(int column, int row);
+
+ JQueryLocator getColumnHeader(int column);
+
+ JQueryLocator getColumnFooter(int column);
+
+ JQueryLocator getHeader();
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableAttributes.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableAttributes.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableAttributes.java 2010-12-06 17:53:17 UTC (rev 20412)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * 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.tests.metamer.ftest.abstractions;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedList;
+
+import org.apache.commons.lang.StringUtils;
+import org.richfaces.model.SortMode;
+import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class DataTableAttributes extends AbstractComponentAttributes {
+ public void setShowData(boolean showData) {
+ setProperty("showData", showData);
+ }
+
+ public void setFirst(Integer first) {
+ setProperty("first", first);
+ }
+
+ public void setNoDataLabel(String noDataLabel) {
+ setProperty("noDataLabel", noDataLabel);
+ }
+
+ public void setRendered(Boolean rendered) {
+ setProperty("rendered", rendered);
+ }
+
+ public void setRows(Integer rows) {
+ setProperty("rows", rows);
+ }
+
+ public int getRows() {
+ return Integer.valueOf(getProperty("rows"));
+ }
+
+ public void setSortMode(SortMode sortMode) {
+ setProperty("sortMode", sortMode);
+ }
+
+ public void setSortPriority(Collection<String> sortPriority) {
+ setProperty("sortPriority", sortPriority);
+ }
+
+ public Collection<String> getSortPriority() {
+ String string = getProperty("sortPriority");
+ return new LinkedList<String>(Arrays.asList(StringUtils.split(string, "[], ")));
+
+ }
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java 2010-12-06 17:53:17 UTC (rev 20412)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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.tests.metamer.ftest.abstractions;
+
+import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class DataTableFacets extends AbstractComponentAttributes {
+
+ public void setNoData(String noData) {
+ throw new UnsupportedOperationException("not implemeneted yet");
+ }
+
+ public void setHeader(String header) {
+ setProperty("header", header);
+ }
+
+ public void setStateHeader(String stateHeader) {
+ setProperty("stateHeader", stateHeader);
+ }
+
+ public void setStateFooter(String stateFooter) {
+ setProperty("stateFooter", stateFooter);
+ }
+
+ public void setCapitalHeader(String capitalHeader) {
+ setProperty("capitalHeader", capitalHeader);
+ }
+
+ public void setCapitalFooter(String capitalFooter) {
+ setProperty("capitalFooter", capitalFooter);
+ }
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacetsTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacetsTest.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacetsTest.java 2010-12-06 17:53:17 UTC (rev 20412)
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * 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.tests.metamer.ftest.abstractions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public abstract class DataTableFacetsTest extends AbstractDataTableTest {
+
+ private static final String SAMPLE_STRING = "Abc123!@#ĚščСам";
+ private static final String EMPTY_STRING = "";
+
+ @Test
+ public void testNoDataInstantChange() {
+ attributes.setShowData(false);
+ facets.setNoData(SAMPLE_STRING);
+ assertEquals(selenium.getText(model.getNoData()), SAMPLE_STRING);
+ }
+
+ @Test
+ public void testNoDataEmpty() {
+ attributes.setShowData(false);
+ facets.setNoData(EMPTY_STRING);
+ assertEquals(selenium.getText(model.getNoData()), EMPTY_STRING);
+ }
+
+ @Test
+ public void testNoDataLabelWithEmptyNoDataFacet() {
+ attributes.setShowData(false);
+ facets.setNoData(EMPTY_STRING);
+ attributes.setNoDataLabel(SAMPLE_STRING);
+ assertEquals(selenium.getText(model.getNoData()), SAMPLE_STRING);
+ }
+
+ @Test
+ public void testHeaderInstantChange() {
+ facets.setHeader(SAMPLE_STRING);
+ assertEquals(selenium.getText(model.getHeader()), SAMPLE_STRING);
+ }
+
+ @Test
+ public void testHeaderEmpty() {
+ facets.setHeader(EMPTY_STRING);
+ assertFalse(selenium.isElementPresent(model.getHeader()));
+ }
+
+ @Test
+ public void testStateHeaderInstantChange() {
+ facets.setStateHeader(SAMPLE_STRING);
+ assertEquals(selenium.getText(model.getColumnHeader(COLUMN_STATE)), SAMPLE_STRING);
+ }
+
+ @Test
+ public void testStateHeaderEmpty() {
+ facets.setStateHeader(EMPTY_STRING);
+ assertFalse(selenium.isElementPresent(model.getColumnHeader(COLUMN_STATE)));
+ }
+
+ @Test
+ public void testStateFooterInstantChange() {
+ facets.setStateHeader(SAMPLE_STRING);
+ assertEquals(selenium.getText(model.getColumnFooter(COLUMN_STATE)), SAMPLE_STRING);
+ }
+
+ @Test
+ public void testStateFooterEmpty() {
+ facets.setStateFooter(EMPTY_STRING);
+ assertFalse(selenium.isElementPresent(model.getColumnFooter(COLUMN_STATE)));
+ }
+
+ @Test
+ public void testCapitalHeaderInstantChange() {
+ facets.setCapitalHeader(SAMPLE_STRING);
+ assertEquals(selenium.getText(model.getColumnHeader(COLUMN_CAPITAL)), SAMPLE_STRING);
+ }
+
+ @Test
+ public void testCapitalHeaderEmpty() {
+ facets.setCapitalHeader(EMPTY_STRING);
+ assertFalse(selenium.isElementPresent(model.getColumnHeader(COLUMN_CAPITAL)));
+ }
+
+ @Test
+ public void testCapitalFooterInstantChange() {
+ facets.setCapitalHeader(SAMPLE_STRING);
+ assertEquals(selenium.getText(model.getColumnFooter(COLUMN_CAPITAL)), SAMPLE_STRING);
+ }
+
+ @Test
+ public void testCapitalFooterEmpty() {
+ facets.setCapitalFooter(EMPTY_STRING);
+ assertFalse(selenium.isElementPresent(model.getColumnFooter(COLUMN_CAPITAL)));
+ }
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFilteringTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFilteringTest.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFilteringTest.java 2010-12-06 17:53:17 UTC (rev 20412)
@@ -0,0 +1,282 @@
+/*******************************************************************************
+ * 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.tests.metamer.ftest.abstractions;
+
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.jboss.test.selenium.locator.option.OptionLocatorFactory.optionValue;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.locator.Attribute;
+import org.jboss.test.selenium.locator.AttributeLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.locator.option.OptionValueLocator;
+import org.richfaces.model.Filter;
+import org.richfaces.tests.metamer.model.Employee;
+import org.richfaces.tests.metamer.model.Employee.Sex;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public abstract class DataTableFilteringTest extends AbstractDataTableTest {
+
+ private static final String[] FILTER_NAMES = new String[] { "ivan", "Гог", null, "Š" };
+ private static final String[] FILTER_TITLES = new String[] { "Director", null, "CEO" };
+ private static final Integer[] FILTER_NUMBER_OF_KIDS = new Integer[] { 2, 100, null, 5 };
+
+ JQueryLocator selectSex = jq("select");
+ JQueryLocator inputName = jq("input");
+ JQueryLocator inputTitle = jq("input");
+ JQueryLocator inputNumberOfKids1 = jq("input");
+ JQueryLocator inputNumberOfKids2 = jq("input");
+
+ FilteringDataTable filtering = new FilteringDataTable();
+
+ public ExpectedEmployee filterEmployee;
+ public List<Employee> expectedEmployees;
+ public int rows;
+
+ @BeforeMethod
+ public void setup() {
+ filterEmployee = new ExpectedEmployee();
+ }
+
+ @Test
+ public void testFilterSex() {
+ filtering.selectSex(Sex.MALE);
+ filterEmployee.sex = Sex.MALE;
+ verifyFiltering();
+
+ filtering.selectSex(Sex.FEMALE);
+ filterEmployee.sex = Sex.FEMALE;
+ verifyFiltering();
+
+ filtering.selectSex(null);
+ filterEmployee.sex = null;
+ verifyFiltering();
+ }
+
+ @Test
+ public void testFilterName() {
+ for (String filterName : FILTER_NAMES) {
+ filtering.selectName(filterName);
+ filterEmployee.name = filterName;
+ verifyFiltering();
+ }
+ }
+
+ @Test
+ public void testFilterTitle() {
+ for (String filterTitle : FILTER_TITLES) {
+ filtering.selectTitle(filterTitle);
+ filterEmployee.title = filterTitle;
+ verifyFiltering();
+ }
+ }
+
+ @Test
+ public void testFilterNumberOfKids1() {
+ for (Integer filterNumberOfKids : FILTER_NUMBER_OF_KIDS) {
+ filtering.selectNumberOfKids1(filterNumberOfKids);
+ filterEmployee.numberOfKids1 = filterNumberOfKids;
+ verifyFiltering();
+ }
+ }
+
+ @Test
+ public void testFilterCombinations() {
+ filtering.selectTitle("Technology");
+ filterEmployee.title = "Technology";
+ verifyFiltering();
+
+ filtering.selectNumberOfKids1(1);
+ filterEmployee.numberOfKids1 = 1;
+ verifyFiltering();
+
+ filtering.selectSex(Sex.MALE);
+ filterEmployee.sex = Sex.MALE;
+ verifyFiltering();
+
+ filtering.selectName("9");
+ filterEmployee.name = "9";
+ verifyFiltering();
+
+ filtering.selectNumberOfKids1(1);
+ filterEmployee.numberOfKids1 = 1;
+ verifyFiltering();
+
+ filtering.selectSex(Sex.FEMALE);
+ filterEmployee.sex = Sex.FEMALE;
+ verifyFiltering();
+ }
+
+ @Test
+ public void testRefresh() {
+ dataScroller1.gotoFirstPage();
+ rows = model.getRows();
+
+ filtering.selectName("an");
+ filterEmployee.name = "an";
+
+ dataScroller1.gotoLastPage();
+ int lastPage = dataScroller1.getCurrentPage();
+ assertTrue(lastPage > 1);
+
+ rerenderAll();
+ assertEquals(dataScroller1.getCurrentPage(), lastPage);
+ verifyPageContent(lastPage);
+
+ fullPageRefresh();
+ assertEquals(dataScroller1.getCurrentPage(), lastPage);
+ verifyPageContent(lastPage);
+ }
+
+ public void verifyFiltering() {
+ expectedEmployees = filter(EMPLOYEES, getFilter());
+
+ dataScroller1.gotoFirstPage();
+ rows = model.getRows();
+ verifyPageContent(1);
+
+ dataScroller1.gotoPage(2);
+ verifyPageContent(2);
+
+ dataScroller1.gotoLastPage();
+ int lastPage = dataScroller1.getCurrentPage();
+ verifyPageContent(lastPage);
+
+ dataScroller1.gotoPage(lastPage - 1);
+ verifyPageContent(lastPage - 1);
+ }
+
+ public void verifyPageContent(int page) {
+ for (int row = 0; row < model.getRows(); row++) {
+ int index = (page - 1) * rows + row;
+ Employee expectedEmployee = expectedEmployees.get(index);
+ filtering.verifyRow(expectedEmployee, row);
+ }
+ }
+
+ private class ExpectedEmployee {
+ Sex sex;
+ String name;
+ String title;
+ Integer numberOfKids1;
+ }
+
+ private Filter<Employee> getFilter() {
+ return new Filter<Employee>() {
+ @Override
+ public boolean accept(Employee employee) {
+ boolean result = true;
+ if (filterEmployee.sex != null) {
+ result &= employee.getSex() == filterEmployee.sex;
+ }
+ if (filterEmployee.name != null) {
+ result &= employee.getName().toLowerCase().contains(filterEmployee.name.toLowerCase());
+ }
+ if (filterEmployee.title != null) {
+ result &= employee.getTitle().equals(filterEmployee.title);
+ }
+ if (filterEmployee.numberOfKids1 != null) {
+ result &= employee.getNumberOfKids() >= filterEmployee.numberOfKids1;
+ }
+ return result;
+ }
+ };
+ }
+
+ @SuppressWarnings("unchecked")
+ private <E, T extends Collection<E>> T filter(T collection, Filter<E> filter) {
+ T filteredCollection;
+ try {
+ filteredCollection = (T) collection.getClass().newInstance();
+
+ for (E element : collection) {
+ if (filter.accept(element)) {
+ filteredCollection.add(element);
+ }
+ }
+
+ return (T) filteredCollection;
+ } catch (Exception e) {
+ throw new IllegalStateException("Cannot construct new collection", e);
+ }
+ }
+
+ private class FilteringDataTable {
+ public void verifyRow(Employee expectedEmployee, int row) {
+ verifySex(expectedEmployee.getSex(), row);
+ verifyElement(COLUMN_NAME, row, expectedEmployee.getName());
+ verifyElement(COLUMN_TITLE, row, expectedEmployee.getTitle());
+ verifyElement(COLUMN_NUMBER_OF_KIDS1, row, expectedEmployee.getNumberOfKids());
+ verifyElement(COLUMN_NUMBER_OF_KIDS2, row, expectedEmployee.getNumberOfKids());
+ }
+
+ public void selectSex(Sex sex) {
+ JQueryLocator select = model.getColumnHeader(COLUMN_SEX).getDescendant(selectSex);
+ OptionValueLocator option = sex == null ? optionValue("ALL") : optionValue(sex.toString());
+ guardXhr(selenium).select(select, option);
+ }
+
+ public void verifySex(Sex expectedSex, int row) {
+ JQueryLocator rowLocator = model.getElement(COLUMN_SEX, row);
+ AttributeLocator<?> sexLocator = rowLocator.getDescendant(jq("img")).getAttribute(Attribute.ALT);
+ String sexString = selenium.getAttribute(sexLocator);
+ Sex actualSex = Sex.valueOf(sexString);
+ assertEquals(actualSex, expectedSex);
+ }
+
+ public void selectName(String name) {
+ JQueryLocator input = model.getColumnHeader(COLUMN_NAME).getDescendant(inputName);
+ selenium.type(inputName, name);
+ guardXhr(selenium).fireEvent(input, Event.BLUR);
+ }
+
+ public void selectTitle(String title) {
+ JQueryLocator input = model.getColumnHeader(COLUMN_TITLE).getDescendant(inputTitle);
+ selenium.type(inputName, title);
+ guardXhr(selenium).fireEvent(input, Event.BLUR);
+ }
+
+ public void selectNumberOfKids1(int numberOfKids) {
+ JQueryLocator input = model.getColumnHeader(COLUMN_NUMBER_OF_KIDS1).getDescendant(inputNumberOfKids1);
+ selenium.type(inputName, Integer.toString(numberOfKids));
+ guardXhr(selenium).fireEvent(input, Event.BLUR);
+ }
+
+ public void verifyElement(int column, int row, Object expectedValue) {
+ JQueryLocator locator = model.getColumnHeader(COLUMN_NAME);
+ String text = selenium.getText(locator);
+ assertEquals(text, expectedValue.toString());
+ }
+
+ }
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableScrollerTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableScrollerTest.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableScrollerTest.java 2010-12-06 17:53:17 UTC (rev 20412)
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.tests.metamer.ftest.abstractions;
+
+import static org.testng.Assert.assertEquals;
+
+import org.richfaces.tests.metamer.ftest.annotations.Templates;
+import org.richfaces.tests.metamer.ftest.model.DataScroller;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public abstract class DataTableScrollerTest extends AbstractDataTableTest {
+
+ @Test
+ public void testRowCountFooterScroller() {
+ testRowCount(dataScroller2);
+ }
+
+ @Test
+ @Templates(exclude = { "a4jRepeat1", "a4jRepeat2", "hDataTable1", "hDataTable2", "richDataTable1,redDiv",
+ "richDataTable2,redDiv", "uiRepeat1", "uiRepeat2" })
+ public void testRowCountOutsideTable() {
+ testRowCount(dataScroller1);
+ }
+
+ private void testRowCount(DataScroller dataScroller) {
+ for (Integer rowsPerPage : COUNTS) {
+ if (rowsPerPage != null) {
+ attributes.setRows(rowsPerPage);
+ selenium.waitForPageToLoad();
+ }
+
+ dataScroller.gotoFirstPage();
+ int rowCountPreset = attributes.getRows();
+ int rowCountActual = model.getRows();
+ assertEquals(rowCountActual, Math.min(ELEMENTS_TOTAL, rowCountPreset));
+
+ assertEquals(dataScroller.hasPages(), rowCountActual < ELEMENTS_TOTAL);
+ if (dataScroller.hasPages()) {
+ dataScroller.gotoLastPage();
+
+ int pagesExpected = pageCountActualExpected(rowCountActual);
+ int countOfVisiblePages = dataScroller.getCountOfVisiblePages();
+
+ if (countOfVisiblePages < pagesExpected) {
+ int lastVisiblePage = dataScroller.getLastVisiblePage();
+ assertEquals(lastVisiblePage, pageCountActualExpected(rowCountActual));
+ } else {
+ assertEquals(countOfVisiblePages, pagesExpected);
+ }
+
+ int rowCountExpected = rowCountLastPageExpected(rowCountPreset);
+ rowCountActual = model.getRows();
+ assertEquals(rowCountActual, rowCountExpected);
+ }
+ }
+ }
+
+ private int pageCountActualExpected(int rowCountActual) {
+ return Double.valueOf(Math.ceil((double) ELEMENTS_TOTAL / rowCountActual)).intValue();
+ }
+
+ private int rowCountLastPageExpected(int rowCountPreset) {
+ int result = ELEMENTS_TOTAL % rowCountPreset;
+ return (result == 0) ? rowCountPreset : result;
+ }
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java 2010-12-06 17:53:17 UTC (rev 20412)
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * 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.tests.metamer.ftest.abstractions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.util.List;
+
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.metamer.ftest.annotations.Inject;
+import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.richfaces.tests.metamer.model.Capital;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public abstract class DataTableSimpleTest extends AbstractDataTableTest {
+
+ protected static final int COLUMNS_TOTAL = 2;
+
+ @Inject
+ protected Integer first = null;
+
+ @Inject
+ protected Integer rows = 30;
+
+ private int expectedFirst;
+ private int expectedRows;
+ private List<Capital> expectedElements;
+
+ @BeforeMethod
+ public void setup() {
+ attributes.setFirst(first);
+ attributes.setRows(rows);
+
+ if (first == null) {
+ expectedFirst = 0;
+ } else {
+ expectedFirst = Math.min(ELEMENTS_TOTAL, first);
+ }
+
+ if (rows == null) {
+ expectedRows = ELEMENTS_TOTAL - first;
+ } else {
+ expectedRows = rows - first;
+ }
+
+ expectedElements = getExpectedElements();
+ }
+
+ @Test
+ public void testRendered() {
+ assertFalse(model.isVisible());
+ assertFalse(model.isNoData());
+ assertEquals(model.getColumns(), 0);
+ assertEquals(model.getRows(), 0);
+ }
+
+ @Test
+ public void testNoDataLabel() {
+ assertTrue(model.isVisible());
+ assertTrue(model.isNoData());
+ assertEquals(model.getColumns(), 0);
+ assertEquals(model.getRows(), 0);
+ assertEquals(selenium.getText(model.getNoData()), "There is no data.");
+ }
+
+ @Test
+ @Use(field = "first", value = "COUNTS")
+ public void testFirst() {
+ verifyTable();
+ }
+
+ @Test
+ @Use(field = "rows", value = "COUNTS")
+ public void testRows() {
+ verifyTable();
+ }
+
+ public void verifyTable() {
+ assertTrue(model.isVisible());
+ assertFalse(model.isNoData());
+ assertEquals(model.getColumns(), COLUMNS_TOTAL);
+ assertEquals(model.getRows(), expectedRows);
+ }
+
+ public void verifyElements() {
+ for (int i = 0; i < expectedRows; i++) {
+ Capital expectedCapital = expectedElements.get(i);
+ JQueryLocator stateLocator = model.getElement(1, i);
+ JQueryLocator capitalLocator = model.getElement(1, i);
+
+ assertEquals(selenium.getText(stateLocator), expectedCapital.getState());
+ assertEquals(selenium.getText(capitalLocator), expectedCapital.getState());
+ }
+ }
+
+ public List<Capital> getExpectedElements() {
+ return CAPITALS.subList(expectedFirst, expectedFirst + expectedRows);
+ }
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSortingTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSortingTest.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSortingTest.java 2010-12-06 17:53:17 UTC (rev 20412)
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * 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.tests.metamer.ftest.abstractions;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.testng.Assert.assertEquals;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.richfaces.model.SortMode;
+import org.richfaces.tests.metamer.model.Employee;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public abstract class DataTableSortingTest extends AbstractDataTableTest {
+
+ @Test
+ public void testSortModeSingle() {
+ attributes.setSortMode(SortMode.single);
+
+ sortByColumn(COLUMN_TITLE);
+ verifySortingByColumns("title");
+
+ sortByColumn(COLUMN_SEX);
+ verifySortingByColumns("sex");
+
+ sortByColumn(COLUMN_NAME);
+ verifySortingByColumns("name");
+
+ sortByColumn(COLUMN_NUMBER_OF_KIDS1);
+ verifySortingByColumns("numberOfKids");
+
+ rerenderAll();
+ verifySortingByColumns("numberOfKids");
+
+ fullPageRefresh();
+ verifySortingByColumns("numberOfKids");
+ }
+
+ @Test
+ public void testSortModeMulti() {
+ attributes.setSortMode(SortMode.single);
+
+ sortByColumn(COLUMN_TITLE);
+ verifySortingByColumns("title");
+
+ sortByColumn(COLUMN_SEX);
+ verifySortingByColumns("title", "sex");
+
+ sortByColumn(COLUMN_NUMBER_OF_KIDS1);
+ verifySortingByColumns("title", "sex", "numberOfKids");
+
+ sortByColumn(COLUMN_NAME);
+ verifySortingByColumns("title", "sex", "numberOfKids", "name");
+
+ sortByColumn(COLUMN_NUMBER_OF_KIDS1);
+ verifySortingByColumns("title", "sex", "name", "numberOfKids");
+
+ sortByColumn(COLUMN_TITLE);
+ verifySortingByColumns("sex", "name", "numberOfKids", "title");
+
+ rerenderAll();
+ verifySortingByColumns("sex", "name", "numberOfKids", "title");
+
+ fullPageRefresh();
+ verifySortingByColumns("sex", "name", "numberOfKids", "title");
+ }
+
+ int rowIndex;
+ int modelIndex;
+ List<Employee> sortedEmployees;
+
+ public void sortByColumn(int column) {
+ selenium.click(model.getColumnHeader(column).getDescendant(jq("a")));
+ }
+
+ public void verifySortingByColumns(String... columns) {
+ Comparator<Employee> employeeComparator = getPropertyComparator(Employee.class, columns);
+ sortedEmployees = new ArrayList<Employee>(EMPLOYEES);
+ Collections.sort(sortedEmployees, employeeComparator);
+
+ int firstPageRows = model.getRows();
+
+ dataScroller1.gotoFirstPage();
+
+ for (rowIndex = 0; rowIndex < model.getRows(); rowIndex++) {
+ modelIndex = rowIndex;
+ verifyRow(rowIndex, modelIndex);
+ }
+
+ dataScroller1.gotoPage(2);
+
+ for (rowIndex = 0; rowIndex < model.getRows(); rowIndex++) {
+ modelIndex = firstPageRows + rowIndex;
+ verifyRow(rowIndex, modelIndex);
+ }
+
+ dataScroller1.gotoLastPage();
+
+ for (rowIndex = 0; rowIndex < model.getRows(); rowIndex++) {
+ modelIndex = EMPLOYEES.size() - model.getRows() + rowIndex;
+ verifyRow(rowIndex, modelIndex);
+ }
+ }
+
+ public void verifyRow(int rowIndex, int modelIndex) {
+ assertEquals(employees.getSex(rowIndex), sortedEmployees.get(modelIndex).getSex());
+ assertEquals(employees.getName(rowIndex), sortedEmployees.get(modelIndex));
+ assertEquals(employees.getTitle(rowIndex), sortedEmployees.get(modelIndex).getTitle());
+ assertEquals(employees.getNumberOfKids(rowIndex), sortedEmployees.get(modelIndex).getNumberOfKids());
+ }
+
+ public <T> Comparator<T> getPropertyComparator(final Class<T> classT, final String... properties) {
+ return new Comparator<T>() {
+
+ @Override
+ public int compare(T o1, T o2) {
+ for (String property : properties) {
+ String getterName = "get" + StringUtils.capitalize(property);
+ try {
+
+ Method getter = classT.getClass().getMethod(getterName);
+ Object got1 = getter.invoke(o1);
+ Object got2 = getter.invoke(o2);
+ Method compareTo = got1.getClass().getMethod("compareTo", got2.getClass());
+ int result = (Integer) compareTo.invoke(got1, got2);
+ if (result != 0) {
+ return result;
+ }
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Cannot obtain property '" + property + "'", e);
+ }
+ }
+ return 0;
+ }
+
+ };
+ }
+}
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAutocomplete/TestAutocompleteByKeys.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAutocomplete/TestAutocompleteByKeys.java 2010-12-06 17:51:19 UTC (rev 20411)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAutocomplete/TestAutocompleteByKeys.java 2010-12-06 17:53:17 UTC (rev 20412)
@@ -29,8 +29,6 @@
import java.util.LinkedList;
import java.util.List;
-import javax.xml.bind.JAXBException;
-
import org.richfaces.tests.metamer.bean.Model;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.richfaces.tests.metamer.ftest.annotations.Inject;
@@ -63,18 +61,10 @@
@Use(booleans = { true, false })
Boolean selectFirst;
- List<Capital> capitals;
+ List<Capital> capitals = Model.unmarshallCapitals();
StringBuilder partialInput;
- {
- try {
- capitals = Model.unmarshallCapitals();
- } catch (JAXBException e) {
- throw new IllegalStateException(e);
- }
- }
-
@BeforeMethod
public void prepareProperties() {
attributes.setAutofill(autofill);
14 years, 1 month
JBoss Rich Faces SVN: r20411 - in modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: a4jRepeat and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-12-06 12:51:19 -0500 (Mon, 06 Dec 2010)
New Revision: 20411
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jRepeat/TestMatrix.java
Log:
added methods rerenderAll() and fullPageRefresh() to AbstractMetamerTest
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-12-06 15:52:12 UTC (rev 20410)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-12-06 17:51:19 UTC (rev 20411)
@@ -21,6 +21,9 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardHttp;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+import static org.jboss.test.selenium.locator.LocatorFactory.id;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
import static org.testng.Assert.assertEquals;
@@ -108,6 +111,20 @@
e.printStackTrace();
}
}
+
+ /**
+ * Do a full page refresh (regular HTTP request) by triggering a command with no action bound.
+ */
+ public void fullPageRefresh() {
+ guardHttp(selenium).click(id("controlsForm:fullPageRefreshImage"));
+ }
+
+ /**
+ * Rerender all content of the page (AJAX request) by trigerring a command with no action but render bound.
+ */
+ public void rerenderAll() {
+ guardXhr(selenium).click(id("controlsForm:reRenderAllImage"));
+ }
/**
* Factory method for creating instances of class JQueryLocator which locates the element using <a
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jRepeat/TestMatrix.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jRepeat/TestMatrix.java 2010-12-06 15:52:12 UTC (rev 20410)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jRepeat/TestMatrix.java 2010-12-06 17:51:19 UTC (rev 20411)
@@ -171,10 +171,6 @@
}
}
- private void rerenderAll() {
- waitXhr(selenium).click(jq("img#controlsForm\\:reRenderAllImage"));
- }
-
private void checkMatrix() {
new MatrixCommand() {
public void processCell(int x, int y) {
14 years, 1 month
JBoss Rich Faces SVN: r20409 - in trunk: ui/dist/richfaces-components-api and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-12-06 10:49:25 -0500 (Mon, 06 Dec 2010)
New Revision: 20409
Modified:
trunk/bom/pom.xml
trunk/ui/dist/richfaces-components-api/pom.xml
trunk/ui/misc/pom.xml
Log:
RF-9927
Modified: trunk/bom/pom.xml
===================================================================
--- trunk/bom/pom.xml 2010-12-06 15:49:22 UTC (rev 20408)
+++ trunk/bom/pom.xml 2010-12-06 15:49:25 UTC (rev 20409)
@@ -97,11 +97,6 @@
</dependency>
<dependency>
<groupId>org.richfaces.ui.misc</groupId>
- <artifactId>richfaces-ui-misc-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.richfaces.ui.misc</groupId>
<artifactId>richfaces-ui-misc-ui</artifactId>
<version>${project.version}</version>
</dependency>
Modified: trunk/ui/dist/richfaces-components-api/pom.xml
===================================================================
--- trunk/ui/dist/richfaces-components-api/pom.xml 2010-12-06 15:49:22 UTC (rev 20408)
+++ trunk/ui/dist/richfaces-components-api/pom.xml 2010-12-06 15:49:25 UTC (rev 20409)
@@ -60,10 +60,6 @@
<groupId>org.richfaces.ui.input</groupId>
<artifactId>richfaces-ui-input-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.richfaces.ui.misc</groupId>
- <artifactId>richfaces-ui-misc-api</artifactId>
- </dependency>
<!-- for javadoc generation -->
<dependency>
Modified: trunk/ui/misc/pom.xml
===================================================================
--- trunk/ui/misc/pom.xml 2010-12-06 15:49:22 UTC (rev 20408)
+++ trunk/ui/misc/pom.xml 2010-12-06 15:49:25 UTC (rev 20409)
@@ -36,7 +36,6 @@
<name>Richfaces UI Components: Miscellanous Aggregator</name>
<modules>
- <module>api</module>
<module>ui</module>
</modules>
14 years, 1 month
JBoss Rich Faces SVN: r20408 - in modules/tests/metamer/trunk/application/src/main: webapp/components and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-12-06 10:49:22 -0500 (Mon, 06 Dec 2010)
New Revision: 20408
Added:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichFileUploadBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richFileUpload/
modules/tests/metamer/trunk/application/src/main/webapp/components/richFileUpload/list.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richFileUpload/simple.xhtml
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
Log:
https://jira.jboss.org/browse/RF-9504
* added sample for rich:fileUpload
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2010-12-06 15:40:46 UTC (rev 20407)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2010-12-06 15:49:22 UTC (rev 20408)
@@ -126,6 +126,7 @@
components.put("richDataScroller", "Rich Data Scroller");
components.put("richDataTable", "Rich Data Table");
components.put("richExtendedDataTable", "Rich Extended Data Table");
+ components.put("richFileUpload", "Rich File Upload");
components.put("richFunctions", "Rich Functions");
components.put("richInplaceInput", "Rich Inplace Input");
components.put("richInplaceSelect", "Rich Inplace Select");
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichFileUploadBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichFileUploadBean.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichFileUploadBean.java 2010-12-06 15:49:22 UTC (rev 20408)
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * 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.tests.metamer.bean;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ViewScoped;
+import org.richfaces.component.UIFileUpload;
+import org.richfaces.event.UploadEvent;
+import org.richfaces.model.UploadItem;
+
+import org.richfaces.tests.metamer.Attributes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Managed bean for rich:fileUpload.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean(name = "richFileUploadBean")
+@ViewScoped
+public class RichFileUploadBean implements Serializable {
+
+ private static final long serialVersionUID = -1L;
+ private static Logger logger;
+ private Attributes attributes;
+ private List<UploadItem> items;
+
+ /**
+ * Initializes the managed bean.
+ */
+ @PostConstruct
+ public void init() {
+ logger = LoggerFactory.getLogger(getClass());
+ logger.debug("initializing bean " + getClass().getName());
+ items = new ArrayList<UploadItem>();
+
+ attributes = Attributes.getUIComponentAttributes(UIFileUpload.class, getClass(), false);
+
+ attributes.setAttribute("enabled", true);
+ attributes.setAttribute("noDuplicate", false);
+ attributes.setAttribute("rendered", true);
+
+ // will be tested in another way
+ attributes.remove("validator");
+ attributes.remove("fileUploadListener");
+ }
+
+ public Attributes getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(Attributes attributes) {
+ this.attributes = attributes;
+ }
+
+ public List<UploadItem> getItems() {
+ return items;
+ }
+
+ public void listener(UploadEvent event) {
+ UploadItem item = event.getUploadItem();
+
+ if (item != null) {
+ items.add(item);
+ item.getFile().delete();
+ }
+ }
+
+ public String clearUploadedData() {
+ items.clear();
+ return null;
+ }
+}
Property changes on: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichFileUploadBean.java
___________________________________________________________________
Name: svn:keywords
+ Revision
Added: modules/tests/metamer/trunk/application/src/main/webapp/components/richFileUpload/list.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richFileUpload/list.xhtml (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richFileUpload/list.xhtml 2010-12-06 15:49:22 UTC (rev 20408)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!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:ui="http://java.sun.com/jsf/facelets"
+ xmlns:metamer="http://java.sun.com/jsf/composite/metamer">
+
+ <!--
+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.
+ -->
+
+ <ui:composition template="/templates/list.xhtml">
+
+ <ui:define name="pageTitle">Rich File Upload</ui:define>
+
+ <ui:define name="links">
+
+ <metamer:testPageLink id="simple" outcome="simple" value="Simple">
+ Simple page containing <b>rich:fileUpload</b> and inputs for all its attributes.
+ </metamer:testPageLink>
+
+ </ui:define>
+
+ </ui:composition>
+
+</html>
Added: modules/tests/metamer/trunk/application/src/main/webapp/components/richFileUpload/simple.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richFileUpload/simple.xhtml (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richFileUpload/simple.xhtml 2010-12-06 15:49:22 UTC (rev 20408)
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!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:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:metamer="http://java.sun.com/jsf/composite/metamer"
+ xmlns:rich="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j">
+
+ <!--
+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.
+ -->
+
+ <ui:composition template="/templates/template.xhtml">
+ <ui:define name="head">
+ <f:metadata>
+ <f:viewParam name="templates" value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ </ui:define>
+
+ <ui:define name="component">
+
+ <rich:fileUpload id="fileUpload"
+ acceptedTypes="#{richFileUploadBean.attributes['acceptedTypes'].value}"
+ dir="#{richFileUploadBean.attributes['dir'].value}"
+ enabled="#{richFileUploadBean.attributes['enabled'].value}"
+ fileUploadListener="#{richFileUploadBean.listener}"
+ lang="#{richFileUploadBean.attributes['lang'].value}"
+ noDuplicate="#{richFileUploadBean.attributes['noDuplicate'].value}"
+ onclick="#{richFileUploadBean.attributes['onclick'].value}"
+ ondblclick="#{richFileUploadBean.attributes['ondblclick'].value}"
+ onfilesubmit="#{richFileUploadBean.attributes['onfilesubmit'].value}"
+ onkeydown="#{richFileUploadBean.attributes['onkeydown'].value}"
+ onkeypress="#{richFileUploadBean.attributes['onkeypress'].value}"
+ onkeyup="#{richFileUploadBean.attributes['onkeyup'].value}"
+ onmousedown="#{richFileUploadBean.attributes['onmousedown'].value}"
+ onmousemove="#{richFileUploadBean.attributes['onmousemove'].value}"
+ onmouseout="#{richFileUploadBean.attributes['onmouseout'].value}"
+ onmouseover="#{richFileUploadBean.attributes['onmouseover'].value}"
+ onmouseup="#{richFileUploadBean.attributes['onmouseup'].value}"
+ onuploadcomplete="#{richFileUploadBean.attributes['onuploadcomplete'].value}"
+ rendered="#{richFileUploadBean.attributes['rendered'].value}"
+ style="#{richFileUploadBean.attributes['style'].value}"
+ styleClass="#{richFileUploadBean.attributes['styleClass'].value}"
+ title="#{richFileUploadBean.attributes['title'].value}"
+ />
+
+ <br/>
+ <fieldset style="width: 376px;">
+ <legend>Uploaded Files</legend>
+ <a4j:outputPanel id="uploadedFilesPanel" ajaxRendered="true">
+ <ul>
+ <a4j:repeat value="#{richFileUploadBean.items}" var="item">
+ <li>#{item.fileName}</li>
+ </a4j:repeat>
+ </ul>
+
+ <br/>
+
+ <a4j:commandButton id="clearUploadedDataButton"
+ action="#{richFileUploadBean.clearUploadedData}"
+ value="Clear Uploaded Data"
+ rendered="#{richFileUploadBean.items.size() > 0}" />
+ </a4j:outputPanel>
+ </fieldset>
+
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <metamer:attributes value="#{richFileUploadBean.attributes}" id="attributes" render="log"/>
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
14 years, 1 month
JBoss Rich Faces SVN: r20407 - in trunk: examples/misc-demo/src/main/java/org/richfaces/demo and 12 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-12-06 10:40:46 -0500 (Mon, 06 Dec 2010)
New Revision: 20407
Removed:
trunk/examples/misc-demo/src/main/java/org/richfaces/demo/FileUploadBean.java
trunk/examples/misc-demo/src/main/java/org/richfaces/demo/SkinBean.java
trunk/examples/misc-demo/src/main/webapp/pages/fileupload.xhtml
trunk/ui/misc/api/src/main/java/org/richfaces/event/FileUploadListener.java
trunk/ui/misc/api/src/main/java/org/richfaces/event/UploadEvent.java
trunk/ui/misc/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java
trunk/ui/misc/ui/src/main/java/org/richfaces/context/
trunk/ui/misc/ui/src/main/java/org/richfaces/exception/
trunk/ui/misc/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
trunk/ui/misc/ui/src/main/java/org/richfaces/request/
trunk/ui/misc/ui/src/main/java/org/richfaces/view/facelets/
trunk/ui/misc/ui/src/main/resources/META-INF/fileupload.faces-config.xml
trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss
trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js
trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fu-add-dis.gif
trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fu-add.gif
trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fu-clr.gif
trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fu-upl.gif
trunk/ui/misc/ui/src/main/resources/META-INF/richfaces/
trunk/ui/misc/ui/src/main/templates/fileupload.template.xml
Modified:
trunk/examples/misc-demo/pom.xml
trunk/examples/misc-demo/src/main/webapp/WEB-INF/web.xml
trunk/examples/misc-demo/src/main/webapp/index.jsp
trunk/ui/misc/ui/pom.xml
Log:
RF-9927
Modified: trunk/examples/misc-demo/pom.xml
===================================================================
--- trunk/examples/misc-demo/pom.xml 2010-12-06 15:35:45 UTC (rev 20406)
+++ trunk/examples/misc-demo/pom.xml 2010-12-06 15:40:46 UTC (rev 20407)
@@ -47,10 +47,6 @@
<groupId>org.richfaces.ui.misc</groupId>
<artifactId>richfaces-ui-misc-ui</artifactId>
</dependency>
- <dependency>
- <groupId>org.richfaces.ui.output</groupId>
- <artifactId>richfaces-ui-output-ui</artifactId>
- </dependency>
<!-- todo remove this dependency -->
<dependency>
<groupId>org.richfaces.ui.core</groupId>
Deleted: trunk/examples/misc-demo/src/main/java/org/richfaces/demo/FileUploadBean.java
===================================================================
--- trunk/examples/misc-demo/src/main/java/org/richfaces/demo/FileUploadBean.java 2010-12-06 15:35:45 UTC (rev 20406)
+++ trunk/examples/misc-demo/src/main/java/org/richfaces/demo/FileUploadBean.java 2010-12-06 15:40:46 UTC (rev 20407)
@@ -1,91 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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 javax.faces.component.UIComponent;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.AjaxBehaviorEvent;
-
-import org.richfaces.event.UploadEvent;
-import org.richfaces.model.UploadItem;
-
-/**
- * @author Konstantin Mishin
- *
- */
-@ManagedBean
-@SessionScoped
-public class FileUploadBean {
-
- private String acceptedTypes;
- private boolean enabled = true;
- private boolean noDuplicate = false;
- private UploadItem item;
-
- public UploadItem getItem() {
- return item;
- }
-
-// public void paint(OutputStream stream, Object object) throws IOException {
-// stream.write(item.getData());
-// }
-
- public void listener(UploadEvent event) throws Exception {
- item = event.getUploadItem();
- if (item != null) {
- item.getFile().delete();
- }
- }
-
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- public boolean isEnabled() {
- return enabled;
- }
-
- public void setNoDuplicate(boolean noDuplicate) {
- this.noDuplicate = noDuplicate;
- }
-
- public boolean isNoDuplicate() {
- return noDuplicate;
- }
-
- public void setAcceptedTypes(String acceptedTypes) {
- this.acceptedTypes = acceptedTypes;
- }
-
- public String getAcceptedTypes() {
- return acceptedTypes;
- }
-
- public void updateAttribute(AjaxBehaviorEvent event) throws AbortProcessingException {
- UIComponent component = (UIComponent) event.getSource();
- String attributeName = (String) component.findComponent("name").getAttributes().get("value");
- Object attributeValue = component.findComponent("value").getAttributes().get("value");
- component.findComponent("fu").getAttributes().put(attributeName, attributeValue);
- }
-}
Deleted: trunk/examples/misc-demo/src/main/java/org/richfaces/demo/SkinBean.java
===================================================================
--- trunk/examples/misc-demo/src/main/java/org/richfaces/demo/SkinBean.java 2010-12-06 15:35:45 UTC (rev 20406)
+++ trunk/examples/misc-demo/src/main/java/org/richfaces/demo/SkinBean.java 2010-12-06 15:40:46 UTC (rev 20407)
@@ -1,29 +0,0 @@
-package org.richfaces.demo;
-
-import javax.faces.bean.ManagedBean;
-import javax.faces.bean.SessionScoped;
-
-@ManagedBean(name = "skinBean")
-@SessionScoped
-public class SkinBean {
-
- private static final String[] SKINS = {"blueSky", "deepMarine", "emeraldTown", "NULL", "ruby", "classic",
- "DEFAULT", "japanCherry", "plain", "wine" };
-
- private String skin = "blueSky";
-
- public SkinBean() {
- skin = "blueSky";
- }
- public String getSkin() {
- return skin;
- }
-
- public void setSkin(String skin) {
- this.skin = skin;
- }
-
- public String[] getSkins() {
- return SKINS;
- }
-}
Modified: trunk/examples/misc-demo/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/examples/misc-demo/src/main/webapp/WEB-INF/web.xml 2010-12-06 15:35:45 UTC (rev 20406)
+++ trunk/examples/misc-demo/src/main/webapp/WEB-INF/web.xml 2010-12-06 15:40:46 UTC (rev 20407)
@@ -4,15 +4,6 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>misc-demo</display-name>
- <context-param>
- <param-name>org.richfaces.fileUpload.maxRequestSize</param-name>
- <param-value>268435456</param-value>
- </context-param>
- <context-param>
- <param-name>org.richfaces.skin</param-name>
- <param-value>#{skinBean.skin}</param-value>
- </context-param>
-
<filter>
<filter-name>Test Identity Filter</filter-name>
<filter-class>org.richfaces.demo.TestIdentityFilter</filter-class>
Modified: trunk/examples/misc-demo/src/main/webapp/index.jsp
===================================================================
--- trunk/examples/misc-demo/src/main/webapp/index.jsp 2010-12-06 15:35:45 UTC (rev 20406)
+++ trunk/examples/misc-demo/src/main/webapp/index.jsp 2010-12-06 15:40:46 UTC (rev 20407)
@@ -6,7 +6,6 @@
<body>
<a href="pages/index.jsf">Facelets</a><br />
- <a href="pages/fileupload.jsf">FileUpload Demo</a><br />
</body>
</html>
\ No newline at end of file
Deleted: trunk/examples/misc-demo/src/main/webapp/pages/fileupload.xhtml
===================================================================
--- trunk/examples/misc-demo/src/main/webapp/pages/fileupload.xhtml 2010-12-06 15:35:45 UTC (rev 20406)
+++ trunk/examples/misc-demo/src/main/webapp/pages/fileupload.xhtml 2010-12-06 15:40:46 UTC (rev 20407)
@@ -1,101 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!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:a4j="http://richfaces.org/a4j"
- xmlns:fu="http://richfaces.org/misc">
-<!--
-JBoss, Home of Professional Open Source
-Copyright ${year}, 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.
--->
- <h:head>
- <title>Richfaces FileUpload Demo</title>
- <style>
- <!--
- .fu .rf-fu-lst {
- height: 500px;
- }
- -->
- </style>
- </h:head>
- <h:body>
- <h:form id="form">
- <h:outputText value="Skin: "/>
- <h:selectOneMenu value="#{skinBean.skin}" onchange="submit();">
- <f:selectItems value="#{skinBean.skins}"/>
- </h:selectOneMenu>
- <br />
- <script type="text/javascript">
- <!--
- var onfilesubmit = function (event) {
- var data = event.rf.data;
- RichFaces.log.info(jQuery("<span><b>onfilesubmit: </b>" + data.name + " " + data.state + "</span>"));
- };
-
- var onuploadcomplete = function (event) {
- var data = event.rf.data;
- var str = "";
- RichFaces.log.info(jQuery("<b>onuploadcomplete:</b>"));
- for (var i in data) {
- var item = data[i];
- RichFaces.log.info(" " + item.name + " " + item.state);
- }
- };
- //-->
- </script>
- <fu:fileUpload id="fu" acceptedTypes="#{fileUploadBean.acceptedTypes}" enabled="#{fileUploadBean.enabled}"
- fileUploadListener="#{fileUploadBean.listener}" noDuplicate="#{fileUploadBean.noDuplicate}"
- onfilesubmit="onfilesubmit(event)" onuploadcomplete="onuploadcomplete(event)"/>
- <h:outputText value="File name:" />
- <a4j:outputPanel ajaxRendered="true">#{fileUploadBean.item.fileName}</a4j:outputPanel>
- <br />
- <h:outputText value="Attribute name: "/>
- <h:inputText id="name"/>
- <h:outputText value="Attribute value: "/>
- <h:inputText id="value"/>
- <h:commandButton value="Update attribute">
- <f:ajax render="fu" execute="name value" listener="#{fileUploadBean.updateAttribute}"/>
- </h:commandButton>
- <br />
- <h:outputText value="AcceptedTypes: " />
- <h:inputText value="#{fileUploadBean.acceptedTypes}">
- <f:ajax render="fu"/>
- </h:inputText>
- <br />
- <h:outputText value="Enabled: " />
- <h:selectBooleanCheckbox value="#{fileUploadBean.enabled}">
- <f:ajax render="fu"/>
- </h:selectBooleanCheckbox>
- <br />
- <h:outputText value="NoDuplicate: " />
- <h:selectBooleanCheckbox value="#{fileUploadBean.noDuplicate}">
- <f:ajax render="fu"/>
- </h:selectBooleanCheckbox>
- <br />
- <input type="submit" />
- <a4j:log />
- </h:form>
- </h:body>
-</html>
Deleted: trunk/ui/misc/api/src/main/java/org/richfaces/event/FileUploadListener.java
===================================================================
--- trunk/ui/misc/api/src/main/java/org/richfaces/event/FileUploadListener.java 2010-12-06 15:35:45 UTC (rev 20406)
+++ trunk/ui/misc/api/src/main/java/org/richfaces/event/FileUploadListener.java 2010-12-06 15:40:46 UTC (rev 20407)
@@ -1,29 +0,0 @@
-/**
- * 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.event;
-
-import javax.faces.event.FacesListener;
-
-public interface FileUploadListener extends FacesListener {
-
- public void processUpload(UploadEvent event);
-}
Deleted: trunk/ui/misc/api/src/main/java/org/richfaces/event/UploadEvent.java
===================================================================
--- trunk/ui/misc/api/src/main/java/org/richfaces/event/UploadEvent.java 2010-12-06 15:35:45 UTC (rev 20406)
+++ trunk/ui/misc/api/src/main/java/org/richfaces/event/UploadEvent.java 2010-12-06 15:40:46 UTC (rev 20407)
@@ -1,80 +0,0 @@
-/**
- * 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.event;
-
-import java.util.List;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-
-import org.richfaces.model.UploadItem;
-
-public class UploadEvent extends FacesEvent {
-
- private static final long serialVersionUID = -7645197191376210068L;
- private List<UploadItem> uploadItems = null;
-
- public UploadEvent(UIComponent component, List<UploadItem> uploadItems) {
- super(component);
- this.uploadItems = uploadItems;
- }
-
- public boolean isAppropriateListener(FacesListener listener) {
- return listener instanceof FileUploadListener;
- }
-
- public void processListener(FacesListener listener) {
- ((FileUploadListener) listener).processUpload(this);
- }
-
- /**
- * Returns UploadItem instance. Returns first element of list of UploadItems in case of multiple upload.
- *
- * @return the uploadItem
- */
- public UploadItem getUploadItem() {
- if (uploadItems != null && uploadItems.size() > 0) {
- return uploadItems.get(0);
- }
- return null;
- }
-
- /**
- * Return list of UploadItems
- *
- * @return the uploadItem
- * @since 3.2.2
- */
- public List<UploadItem> getUploadItems() {
- return uploadItems;
- }
-
- /**
- * Return true if multiple files were uploaded with form
- *
- * @return boolean
- * @since 3.2.2
- */
- public boolean isMultiUpload() {
- return uploadItems != null && uploadItems.size() > 1;
- }
-}
Modified: trunk/ui/misc/ui/pom.xml
===================================================================
--- trunk/ui/misc/ui/pom.xml 2010-12-06 15:35:45 UTC (rev 20406)
+++ trunk/ui/misc/ui/pom.xml 2010-12-06 15:40:46 UTC (rev 20407)
@@ -59,10 +59,6 @@
<groupId>org.richfaces.ui.core</groupId>
<artifactId>richfaces-ui-core-ui</artifactId>
</dependency>
- <dependency>
- <groupId>org.richfaces.ui.misc</groupId>
- <artifactId>richfaces-ui-misc-api</artifactId>
- </dependency>
</dependencies>
<profiles>
Deleted: trunk/ui/misc/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java
===================================================================
--- trunk/ui/misc/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java 2010-12-06 15:35:45 UTC (rev 20406)
+++ trunk/ui/misc/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java 2010-12-06 15:40:46 UTC (rev 20407)
@@ -1,128 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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;
-
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.ComponentSystemEvent;
-import javax.faces.event.ListenerFor;
-import javax.faces.event.PostAddToViewEvent;
-
-import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.EventName;
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.cdk.annotations.Tag;
-import org.richfaces.context.FileUploadPartialViewContextFactory;
-import org.richfaces.event.FileUploadListener;
-import org.richfaces.request.MultipartRequest;
-
-/**
- * @author Konstantin Mishin
- *
- */
-@JsfComponent(tag = @Tag(handler = "org.richfaces.view.facelets.FileUploadHandler"),
- renderer = @JsfRenderer(type = "org.richfaces.FileUploadRenderer"),
- attributes = {"events-props.xml", "core-props.xml", "i18n-props.xml"})
-@ListenerFor(systemEventClass = PostAddToViewEvent.class)
-public abstract class AbstractFileUpload extends UIComponentBase {
-
- @Attribute
- public abstract String getAcceptedTypes();
-
- @Attribute(defaultValue = "true")
- public abstract boolean isEnabled();
-
- @Attribute(defaultValue = "false")
- public abstract boolean isNoDuplicate();
-
- @Attribute(events = @EventName("filesubmit"))
- public abstract String getOnfilesubmit();
-
- @Attribute(events = @EventName("uploadcomplete"))
- public abstract String getOnuploadcomplete();
-
- @Override
- public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
- super.processEvent(event);
- FacesContext context = getFacesContext();
- Map<String, UIComponent> facets = getFacets();
- UIComponent component = facets.get("progress");
- if (component == null) {
- try {
- component = context.getApplication().createComponent(context, "org.richfaces.ProgressBar",
- "org.richfaces.ProgressBarRenderer");
- } catch (FacesException e) {
- // To work without ProgressBar.
- }
- if (component != null) {
- component.setId(getId() + "_pb");
- facets.put("progress", component);
- }
- }
- if (component != null) {
- component.setValueExpression("value", context.getApplication().getExpressionFactory()
- .createValueExpression(context.getELContext(),
- "#{" + MultipartRequest.PERCENT_BEAN_NAME + "[param['"
- + FileUploadPartialViewContextFactory.UID_KEY + "']]}", Integer.class));
- }
- }
-
- /**
- * <p>Add a new {@link FileUploadListener} to the set of listeners
- * interested in being notified when {@link UploadEvent}s occur.</p>
- *
- * @param listener The {@link FileUploadListener} to be added
- * @throws NullPointerException if <code>listener</code>
- * is <code>null</code>
- */
- public void addFileUploadListener(FileUploadListener listener) {
- addFacesListener(listener);
- }
-
- /**
- * <p>Return the set of registered {@link FileUploadListener}s for this
- * {@link AbstractFileUpload} instance. If there are no registered listeners,
- * a zero-length array is returned.</p>
- */
- public FileUploadListener[] getFileUploadListeners() {
- return (FileUploadListener[]) getFacesListeners(FileUploadListener.class);
- }
-
- /**
- * <p>Remove an existing {@link FileUploadListener} (if any) from the
- * set of listeners interested in being notified when
- * {@link FileUploadListener}s occur.</p>
- *
- * @param listener The {@link FileUploadListener} to be removed
- * @throws NullPointerException if <code>listener</code>
- * is <code>null</code>
- */
- public void removeFileUploadListener(FileUploadListener listener) {
- removeFacesListener(listener);
- }
-}
\ No newline at end of file
Deleted: trunk/ui/misc/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
===================================================================
--- trunk/ui/misc/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2010-12-06 15:35:45 UTC (rev 20406)
+++ trunk/ui/misc/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2010-12-06 15:40:46 UTC (rev 20407)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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 javax.faces.component.UIComponent;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-
-import org.richfaces.event.UploadEvent;
-import org.richfaces.request.MultipartRequest;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class FileUploadRendererBase extends RendererBase {
-
- @Override
- protected void doDecode(FacesContext context, UIComponent component) {
- ExternalContext externalContext = context.getExternalContext();
- Object request = externalContext.getRequest();
- if (request instanceof MultipartRequest
- && externalContext.getRequestParameterMap().containsKey(component.getClientId(context))) {
- component.queueEvent(new UploadEvent(component, ((MultipartRequest) request).getUploadItems()));
- }
- }
-}
Deleted: trunk/ui/misc/ui/src/main/resources/META-INF/fileupload.faces-config.xml
===================================================================
--- trunk/ui/misc/ui/src/main/resources/META-INF/fileupload.faces-config.xml 2010-12-06 15:35:45 UTC (rev 20406)
+++ trunk/ui/misc/ui/src/main/resources/META-INF/fileupload.faces-config.xml 2010-12-06 15:40:46 UTC (rev 20407)
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-JBoss, Home of Professional Open Source
-Copyright ${year}, 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.
--->
-<faces-config version="2.0"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
- xmlns="http://java.sun.com/xml/ns/javaee" xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <factory>
- <partial-view-context-factory>org.richfaces.context.FileUploadPartialViewContextFactory</partial-view-context-factory>
- </factory>
-</faces-config>
Deleted: trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss
===================================================================
--- trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss 2010-12-06 15:35:45 UTC (rev 20406)
+++ trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss 2010-12-06 15:40:46 UTC (rev 20407)
@@ -1,176 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.
- */
-.rf-fu {
- background: '#{richSkin.generalBackgroundColor}';
- border-color: '#{richSkin.panelBorderColor}';
- border-style: solid;
- border-width: 1px;
- width: 400px; /*TODO Remove it*/
-}
-
-.rf-fu-hdr {
- background-color: '#{richSkin.headerBackgroundColor}';
- background-image: url("#{resource['org.richfaces.renderkit.html.GradientA']}");
- border-color: '#{richSkin.headerBackgroundColor}';
- border-style: solid;
- border-width: 1px;
- margin-left: 1px;
- margin-top: 1px;
- white-space: nowrap;
-}
-
-.rf-fu-lst {
- height: 210px; /*TODO Remove it*/
- overflow-x: hidden;
- overflow-y: auto;
-}
-
-.rf-fu-cntr-hdn {
- display: none;
-}
-
-.rf-fu-btns-lft, .rf-fu-btns-rgh, .rf-fu-itm-lft, .rf-fu-itm-rgh {
- display: inline-block;
- overflow: hidden;
-}
-
-.rf-fu-btns-lft {
- width: 66%;
-}
-
-.rf-fu-btns-rgh {
- text-align: right;
- width: 34%;
-}
-
-.rf-fu-btn-add, .rf-fu-btn-add-dis, .rf-fu-btn-upl, .rf-fu-btn-clr {
- background-position:left top;
- background-repeat:repeat-x;
- border-style: solid;
- border-width: 1px;
- cursor: default;
- display: inline-block;
- margin: 4px;
- vertical-align: top;
-}
-
-.rf-fu-btn-add, .rf-fu-btn-upl, .rf-fu-btn-clr {
- background-color: '#{richSkin.trimColor}';
- background-image: url("#{resource['org.richfaces.images:fuBtnGrad.png']}");
- border-color: '#{richSkin.panelBorderColor}';
-}
-
-.rf-fu-btn-add-dis {
- background-color: '#{richSkin.tableFooterBackgroundColor}';
- background-image: url("#{resource['org.richfaces.images:fuBtnDisGrad.png']}");
- border-color: '#{richSkin.tableFooterBackgroundColor}';
-}
-
-.rf-fu-btn-upl, .rf-fu-btn-clr {
- display: none;
-}
-
-.rf-fu-btn-cnt-add, .rf-fu-btn-cnt-add-dis, .rf-fu-btn-cnt-upl, .rf-fu-btn-cnt-clr, .rf-fu-itm-lbl, .rf-fu-itm-st, .rf-fu-itm-lnk {
- font-family: '#{richSkin.generalFamilyFont}';
- font-size: '#{richSkin.generalSizeFont}';
-}
-
-.rf-fu-btn-cnt-add, .rf-fu-btn-cnt-upl, .rf-fu-btn-cnt-clr, .rf-fu-itm-lbl, .rf-fu-itm-st {
- color: '#{richSkin.generalTextColor}';
-}
-
-.rf-fu-btn-cnt-add, .rf-fu-btn-cnt-add-dis, .rf-fu-btn-cnt-upl, .rf-fu-btn-cnt-clr {
- background-position: 2px 2px;
- background-repeat: no-repeat;
- display: inline-block;
- padding: 3px 5px 3px 21px;
-}
-
-.rf-fu-btn-cnt-add {
- background-image: url("#{resource['org.richfaces:fu-add.gif']}");
- overflow: hidden;
- position: relative;
-}
-
-.rf-fu-btn-cnt-add-dis {
- background-image: url("#{resource['org.richfaces:fu-add-dis.gif']}");
- color: '#{richSkin.tabDisabledTextColor}';
-}
-
-.rf-fu-btn-cnt-upl, .rf-fu-itm-st {
- font-weight: bold;
-}
-
-.rf-fu-btn-cnt-upl {
- background-image: url("#{resource['org.richfaces:fu-upl.gif']}");
-}
-
-.rf-fu-btn-cnt-clr {
- background-image: url("#{resource['org.richfaces:fu-clr.gif']}");
-}
-
-.rf-fu-inp-cntr {
- display: block;
- height: 1px;
- position: absolute;
- right: 0;
- top: 0;
-}
-
-.rf-fu-inp {
- filter: "alpha(opacity=0)";
- font-size: 10em;
- margin: 0;
- opacity: 0;
- position: absolute;
- right: 0;
- top: 0;
-}
-
-.rf-fu-itm {
- border-bottom-color: '#{richSkin.panelBorderColor}';
- border-bottom-style: solid;
- border-bottom-width: 1px;
- padding: 12px;
- white-space: nowrap;
-}
-
-.rf-fu-itm-lft, .rf-fu-itm-rgh {
- vertical-align: middle;
-}
-
-.rf-fu-itm-lft {
- width: 85%;
-}
-
-.rf-fu-itm-rgh {
- width: 14%;
-}
-
-.rf-fu-itm-lnk {
- color: '#{richSkin.generalLinkColor}';
-}
-
-.rf-fu-itm-st {
- display: none;
- margin-top: 5px;
-}
\ No newline at end of file
Deleted: trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js
===================================================================
--- trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js 2010-12-06 15:35:45 UTC (rev 20406)
+++ trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js 2010-12-06 15:40:46 UTC (rev 20407)
@@ -1,274 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.
- */
-(function(richfaces, jQuery) {
-
- var UID = "rf_fu_uid";
-
- var ITEM_HTML = '<div class="rf-fu-itm">'
- + '<span class="rf-fu-itm-lft"><span class="rf-fu-itm-lbl"/><span class="rf-fu-itm-st"/></span>'
- + '<span class="rf-fu-itm-rgh"><a href="javascript:void(0)" class="rf-fu-itm-lnk"/></span></div>';
-
- var ITEM_STATE = {
- NEW: "new",
- UPLOADING: "uploading",
- DONE: "done",
- SIZE_EXCEEDED: "sizeExceeded",
- STOPPED: "stopped",
- SERVER_ERROR: "serverError"
- };
-
- var pressButton = function(event) {
- jQuery(this).children(":first").css("background-position", "3px 3px").css("padding", "4px 4px 2px 22px");
- };
-
- var unpressButton = function(event) {
- jQuery(this).children(":first").css("background-position", "2px 2px").css("padding", "3px 5px 3px 21px");
- };
-
- richfaces.ui = richfaces.ui || {};
-
- richfaces.ui.FileUpload = richfaces.BaseComponent.extendClass({
-
- name: "FileUpload",
-
- items: [],
- submitedItems: [],
-
- doneLabel: "Done",
- sizeExceededLabel: "File size is exceeded",
- stoppedLabel: "",
- serverErrorLabel: "Server error",
- clearLabel: "Clear",
- deleteLabel: "Delete",
-
- init: function(id, options) {
- this.id = id;
- jQuery.extend(this, options);
- if (this.acceptedTypes) {
- this.acceptedTypes = jQuery.trim(this.acceptedTypes).split(/\s*,\s*/);
- }
- this.element = jQuery(this.attachToDom());
- this.form = this.element.parents("form:first");
- var header = this.element.children(".rf-fu-hdr:first");
- var leftButtons = header.children(".rf-fu-btns-lft:first");
- this.addButton = leftButtons.children(".rf-fu-btn-add:first");
- this.uploadButton = this.addButton.next();
- this.clearButton = leftButtons.next().children(".rf-fu-btn-clr:first");
- this.inputContainer = this.addButton.find(".rf-fu-inp-cntr:first");
- this.input = this.inputContainer.children("input");
- this.list = header.next();
- this.hiddenContainer = this.list.next();
- this.iframe = this.hiddenContainer.children("iframe:first");
- this.progressBarElement = this.iframe.next();
- this.progressBar = richfaces.$(this.progressBarElement);
- this.cleanInput = this.input.clone();
- this.addProxy = jQuery.proxy(this.__addItem, this);
- this.input.change(this.addProxy);
- this.addButton.mousedown(pressButton).mouseup(unpressButton).mouseout(unpressButton);
- this.uploadButton.click(jQuery.proxy(this.__startUpload, this)).mousedown(pressButton)
- .mouseup(unpressButton).mouseout(unpressButton);
- this.clearButton.click(jQuery.proxy(this.__removeAllItems, this)).mousedown(pressButton)
- .mouseup(unpressButton).mouseout(unpressButton);
- this.iframe.load(jQuery.proxy(this.__load, this));
- if (this.onfilesubmit) {
- richfaces.Event.bind(this.element, "onfilesubmit", new Function("event", this.onfilesubmit));
- }
- if (this.onuploadcomplete) {
- richfaces.Event.bind(this.element, "onuploadcomplete", new Function("event", this.onuploadcomplete));
- }
- },
-
- __addItem: function() {
- var fileName = this.input.val();
- if (this.__accept(fileName) && (!this.noDuplicate || !this.__isFileAlreadyAdded(fileName))) {
- this.input.hide();
- this.input.unbind("change", this.addProxy);
- var item = new Item(this);
- this.list.append(item.getJQuery());
- this.items.push(item);
- this.input = this.cleanInput.clone();
- this.inputContainer.append(this.input);
- this.input.change(this.addProxy);
- this.__updateButtons();
- }
- },
-
- __removeItem: function(item) {
- this.items.splice(this.items.indexOf(item), 1);
- this.submitedItems.splice(this.submitedItems.indexOf(item), 1);
- this.__updateButtons();
- },
-
- __removeAllItems: function(item) {
- this.inputContainer.children(":not(:visible)").remove();
- this.list.empty();
- this.items.splice(0);
- this.submitedItems.splice(0);
- this.__updateButtons();
- },
-
- __updateButtons: function() {
- if (!this.loadableItem && this.list.children(".rf-fu-itm").size()) {
- if (this.items.length) {
- this.uploadButton.css("display", "inline-block");
- } else {
- this.uploadButton.hide();
- }
- this.clearButton.css("display", "inline-block");
- } else {
- this.uploadButton.hide();
- this.clearButton.hide();
- }
- },
-
- __startUpload: function() {
- this.loadableItem = this.items.shift();
- this.__updateButtons();
- this.loadableItem.startUploading();
- },
-
- __submit: function() {
- var originalAction = this.form.attr("action");
- var originalEncoding = this.form.attr("encoding");
- var originalEnctype = this.form.attr("enctype");
- try {
- this.form.attr("action", originalAction + "?" + UID + "=" + this.loadableItem.uid);
- this.form.attr("encoding", "multipart/form-data");
- this.form.attr("enctype", "multipart/form-data");
- richfaces.submitForm(this.form, {"org.richfaces.ajax.component": this.id}, this.id);
- richfaces.Event.fire(this.element, "onfilesubmit", this.loadableItem.model);
- } finally {
- this.form.attr("action", originalAction);
- this.form.attr("encoding", originalEncoding);
- this.form.attr("enctype", originalEnctype);
- this.loadableItem.input.removeAttr("name");
- }
- },
-
- __load: function(event) {
- if (this.loadableItem) {
- var contentDocument = event.target.contentWindow.document;
- contentDocument = contentDocument.XMLDocument || contentDocument;
- var documentElement = contentDocument.documentElement;
- var responseStatus, id;
- if (documentElement.tagName.toUpperCase() == "PARTIAL-RESPONSE") {
- responseStatus = ITEM_STATE.DONE;
- } else if ((id = documentElement.id) && id.indexOf(UID + this.loadableItem.uid + ":") == 0) {
- responseStatus = id.split(":")[1];
- }
- if (responseStatus) {
- responseStatus == ITEM_STATE.DONE && jsf.ajax.response({responseXML: contentDocument}, {});
- this.loadableItem.finishUploading(responseStatus);
- this.submitedItems.push(this.loadableItem);
- if (responseStatus == ITEM_STATE.DONE && this.items.length) {
- this.__startUpload();
- } else {
- this.loadableItem = null;
- this.__updateButtons();
- var items = [];
- for (var i in this.submitedItems) {
- items.push(this.submitedItems[i].model);
- }
- for (var i in this.items) {
- items.push(this.items[i].model);
- }
- richfaces.Event.fire(this.element, "onuploadcomplete", items);
- }
- }
- }
- },
-
- __accept: function(fileName) {
- var result = !this.acceptedTypes;
- for (var i = 0; !result && i < this.acceptedTypes.length; i++) {
- var extension = this.acceptedTypes[i];
- result = fileName.indexOf(extension, fileName.length - extension.length) !== -1;
- }
- return result;
- },
-
- __isFileAlreadyAdded: function(fileName) {
- var result = false;
- for (var i = 0; !result && i < this.items.length; i++) {
- result = this.items[i].model.name == fileName;
- }
- result = result || (this.loadableItem && this.loadableItem.model.name == fileName);
- for (var i = 0; !result && i < this.submitedItems.length; i++) {
- result = this.submitedItems[i].model.name == fileName;
- }
- return result;
- }
- });
-
- var Item = function(fileUpload) {
- this.fileUpload = fileUpload;
- this.input = fileUpload.input;
- this.model = {name: this.input.val(), state: ITEM_STATE.NEW};
- };
-
- jQuery.extend(Item.prototype, {
- getJQuery: function() {
- this.element = jQuery(ITEM_HTML);
- var leftArea = this.element.children(".rf-fu-itm-lft:first");
- this.label = leftArea.children(".rf-fu-itm-lbl:first");
- this.state = this.label.nextAll(".rf-fu-itm-st:first");
- this.link = leftArea.next().children("a");
- this.label.html(this.model.name);
- this.link.html(this.fileUpload["deleteLabel"]);
- this.link.click(jQuery.proxy(this.removeOrStop, this));
- return this.element;
- },
-
- removeOrStop: function() {
- this.input.remove();
- this.element.remove();
- this.fileUpload.__removeItem(this);
- },
-
- startUploading: function() {
- this.state.css("display", "block");
- this.link.html("");
- this.input.attr("name", this.fileUpload.id);
- this.model.state = ITEM_STATE.UPLOADING;
- this.uid = Math.random();
- this.fileUpload.__submit();
- var params = {};
- params[UID] = this.uid;
- if (this.fileUpload.progressBar) {
- this.fileUpload.progressBar.setValue(0);
- this.state.html(this.fileUpload.progressBarElement.detach());
- this.fileUpload.progressBar.enable(params);
- }
- },
-
- finishUploading: function(state) {
- if (this.fileUpload.progressBar) {
- this.fileUpload.progressBar.disable();
- this.fileUpload.hiddenContainer.append(this.fileUpload.progressBarElement.detach());
- }
- this.input.remove();
- this.state.html(this.fileUpload[state + "Label"]);
- this.link.html(this.fileUpload["clearLabel"]);
- this.model.state = state;
- }
- });
-}(window.RichFaces, jQuery));
Deleted: trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fu-add-dis.gif
===================================================================
(Binary files differ)
Deleted: trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fu-add.gif
===================================================================
(Binary files differ)
Deleted: trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fu-clr.gif
===================================================================
(Binary files differ)
Deleted: trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fu-upl.gif
===================================================================
(Binary files differ)
Deleted: trunk/ui/misc/ui/src/main/templates/fileupload.template.xml
===================================================================
--- trunk/ui/misc/ui/src/main/templates/fileupload.template.xml 2010-12-06 15:35:45 UTC (rev 20406)
+++ trunk/ui/misc/ui/src/main/templates/fileupload.template.xml 2010-12-06 15:40:46 UTC (rev 20407)
@@ -1,91 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-JBoss, Home of Professional Open Source
-Copyright ${year}, 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.
--->
-<cdk:root xmlns="http://jboss.org/schema/richfaces/cdk/xhtml-el" xmlns:cdk="http://jboss.org/schema/richfaces/cdk/core"
- xmlns:cc="http://jboss.org/schema/richfaces/cdk/jsf/composite" xmlns:c="http://jboss.org/schema/richfaces/cdk/jstl/core"
- xmlns:xi="http://www.w3.org/2001/XInclude">
- <cc:interface>
- <cdk:class>org.richfaces.renderkit.html.FileUploadRenderer</cdk:class>
- <cdk:superclass>org.richfaces.renderkit.FileUploadRendererBase</cdk:superclass>
- <cdk:component-family>org.richfaces.FileUpload</cdk:component-family>
- <cdk:renderer-type>org.richfaces.FileUploadRenderer</cdk:renderer-type>
- <cdk:resource-dependency library="org.richfaces" name="fileupload.ecss" />
- <cdk:resource-dependency library="org.richfaces" name="ajax.reslib" />
- <cdk:resource-dependency library="org.richfaces" name="base-component.reslib" />
- <cdk:resource-dependency name="richfaces-event.js" />
- <cdk:resource-dependency library="org.richfaces" name="fileupload.js" />
- </cc:interface>
- <cc:implementation>
- <cdk:object name="attributes" value="#{component.attributes}"/>
- <cdk:object name="enabled" value="#{attributes['enabled']}"/>
- <div id="#{clientId}" class="rf-fu #{attributes['styleClass']}"
- cdk:passThroughWithExclusions="">
- <div class="rf-fu-hdr">
- <span class="rf-fu-btns-lft">
- <span class="rf-fu-btn-add#{enabled ? '' : '-dis'}">
- <span class="rf-fu-btn-cnt-add#{enabled ? '' : '-dis'}">
- <c:if test="#{enabled}">
- <span class="rf-fu-inp-cntr"> <!-- This span is needed for IE7 only. -->
- <input type="file" class="rf-fu-inp"/>
- </span>
- </c:if>
- <cdk:object name="addLabel" value="#{attributes['addLabel']}"/>
- #{addLabel != null ? addLabel : 'Add...'}
- </span>
- </span>
- <c:if test="#{enabled}">
- <span class="rf-fu-btn-upl">
- <cdk:object name="uploadLabel" value="#{attributes['uploadLabel']}"/>
- <span class="rf-fu-btn-cnt-upl">#{uploadLabel != null ? uploadLabel : 'Upload'}</span>
- </span>
- </c:if>
- </span>
- <c:if test="#{enabled}">
- <span class="rf-fu-btns-rgh">
- <span class="rf-fu-btn-clr">
- <cdk:object name="clearAllLabel" value="#{attributes['clearAllLabel']}"/>
- <span class="rf-fu-btn-cnt-clr">#{clearAllLabel != null ? clearAllLabel : 'Clear All'}</span>
- </span>
- </span>
- </c:if>
- </div>
- <div class="rf-fu-lst"/>
- <c:if test="#{enabled}">
- <div class="rf-fu-cntr-hdn">
- <iframe name="#{clientId}"/>
- <cdk:object name="progressBar" value="#{component.facets['progress']}"/>
- <c:if test="#{progressBar != null and progressBar.isRendered()}">
- <cdk:call expression="progressBar.encodeAll(facesContext)" />
- </c:if>
- </div>
- <cdk:scriptObject name="options">
- <cdk:scriptOption attributes="acceptedTypes noDuplicate onfilesubmit onuploadcomplete doneLabel
- sizeExceededLabel stoppedLabel serverErrorLabel clearLabel deleteLabel"/>
- </cdk:scriptObject>
- <script type="text/javascript">new RichFaces.ui.FileUpload(#{toScriptArgs(clientId, options)});</script>
- </c:if>
- </div>
- </cc:implementation>
-</cdk:root>
14 years, 1 month
JBoss Rich Faces SVN: r20406 - in trunk: examples/input-demo/src/main/java/org/richfaces/demo and 12 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-12-06 10:35:45 -0500 (Mon, 06 Dec 2010)
New Revision: 20406
Added:
trunk/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java
trunk/examples/input-demo/src/main/webapp/examples/fileupload.xhtml
trunk/ui/input/api/src/main/java/org/richfaces/event/FileUploadListener.java
trunk/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java
trunk/ui/input/ui/src/main/java/org/richfaces/context/
trunk/ui/input/ui/src/main/java/org/richfaces/exception/
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
trunk/ui/input/ui/src/main/java/org/richfaces/request/
trunk/ui/input/ui/src/main/java/org/richfaces/view/facelets/FileUploadHandler.java
trunk/ui/input/ui/src/main/resources/META-INF/fileupload.faces-config.xml
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-add-dis.gif
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-add.gif
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-clr.gif
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-upl.gif
trunk/ui/input/ui/src/main/templates/fileupload.template.xml
Modified:
trunk/examples/input-demo/pom.xml
trunk/examples/input-demo/src/main/webapp/WEB-INF/faces-config.xml
trunk/examples/input-demo/src/main/webapp/WEB-INF/web.xml
trunk/examples/input-demo/src/main/webapp/templates/template.xhtml
trunk/ui/input/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties
Log:
RF-9927
Modified: trunk/examples/input-demo/pom.xml
===================================================================
--- trunk/examples/input-demo/pom.xml 2010-12-06 15:27:17 UTC (rev 20405)
+++ trunk/examples/input-demo/pom.xml 2010-12-06 15:35:45 UTC (rev 20406)
@@ -108,6 +108,10 @@
<artifactId>richfaces-ui-input-ui</artifactId>
</dependency>
<dependency>
+ <groupId>org.richfaces.ui.output</groupId>
+ <artifactId>richfaces-ui-output-ui</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.richfaces.ui.core</groupId>
<artifactId>richfaces-ui-core-ui</artifactId>
</dependency>
Copied: trunk/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java (from rev 20389, trunk/examples/misc-demo/src/main/java/org/richfaces/demo/FileUploadBean.java)
===================================================================
--- trunk/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java (rev 0)
+++ trunk/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java 2010-12-06 15:35:45 UTC (rev 20406)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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 javax.faces.component.UIComponent;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.AjaxBehaviorEvent;
+
+import org.richfaces.event.UploadEvent;
+import org.richfaces.model.UploadItem;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+@ManagedBean
+@SessionScoped
+public class FileUploadBean {
+
+ private String acceptedTypes;
+ private boolean enabled = true;
+ private boolean noDuplicate = false;
+ private UploadItem item;
+
+ public UploadItem getItem() {
+ return item;
+ }
+
+// public void paint(OutputStream stream, Object object) throws IOException {
+// stream.write(item.getData());
+// }
+
+ public void listener(UploadEvent event) throws Exception {
+ item = event.getUploadItem();
+ if (item != null) {
+ item.getFile().delete();
+ }
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setNoDuplicate(boolean noDuplicate) {
+ this.noDuplicate = noDuplicate;
+ }
+
+ public boolean isNoDuplicate() {
+ return noDuplicate;
+ }
+
+ public void setAcceptedTypes(String acceptedTypes) {
+ this.acceptedTypes = acceptedTypes;
+ }
+
+ public String getAcceptedTypes() {
+ return acceptedTypes;
+ }
+
+ public void updateAttribute(AjaxBehaviorEvent event) throws AbortProcessingException {
+ UIComponent component = (UIComponent) event.getSource();
+ String attributeName = (String) component.findComponent("name").getAttributes().get("value");
+ Object attributeValue = component.findComponent("value").getAttributes().get("value");
+ component.findComponent("fu").getAttributes().put(attributeName, attributeValue);
+ }
+}
Modified: trunk/examples/input-demo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/WEB-INF/faces-config.xml 2010-12-06 15:27:17 UTC (rev 20405)
+++ trunk/examples/input-demo/src/main/webapp/WEB-INF/faces-config.xml 2010-12-06 15:35:45 UTC (rev 20406)
@@ -31,6 +31,10 @@
<from-outcome>calendar</from-outcome>
<to-view-id>/examples/calendar.xhtml</to-view-id>
</navigation-case>
+ <navigation-case>
+ <from-outcome>fileUpload</from-outcome>
+ <to-view-id>/examples/fileupload.xhtml</to-view-id>
+ </navigation-case>
<!-- QUnit -->
Modified: trunk/examples/input-demo/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/WEB-INF/web.xml 2010-12-06 15:27:17 UTC (rev 20405)
+++ trunk/examples/input-demo/src/main/webapp/WEB-INF/web.xml 2010-12-06 15:35:45 UTC (rev 20406)
@@ -39,6 +39,10 @@
<display-name></display-name>
<description></description>
<context-param>
+ <param-name>org.richfaces.fileUpload.maxRequestSize</param-name>
+ <param-value>268435456</param-value>
+ </context-param>
+ <context-param>
<param-name>org.richfaces.skin</param-name>
<param-value>#{skinBean.skin}</param-value>
</context-param>
Copied: trunk/examples/input-demo/src/main/webapp/examples/fileupload.xhtml (from rev 20389, trunk/examples/misc-demo/src/main/webapp/pages/fileupload.xhtml)
===================================================================
--- trunk/examples/input-demo/src/main/webapp/examples/fileupload.xhtml (rev 0)
+++ trunk/examples/input-demo/src/main/webapp/examples/fileupload.xhtml 2010-12-06 15:35:45 UTC (rev 20406)
@@ -0,0 +1,101 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!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:a4j="http://richfaces.org/a4j"
+ xmlns:fu="http://richfaces.org/input">
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, 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.
+-->
+ <h:head>
+ <title>Richfaces FileUpload Demo</title>
+ <style>
+ <!--
+ .fu .rf-fu-lst {
+ height: 500px;
+ }
+ -->
+ </style>
+ </h:head>
+ <h:body>
+ <h:form id="form">
+ <h:outputText value="Skin: "/>
+ <h:selectOneMenu value="#{skinBean.skin}" onchange="submit();">
+ <f:selectItems value="#{skinBean.skins}"/>
+ </h:selectOneMenu>
+ <br />
+ <script type="text/javascript">
+ <!--
+ var onfilesubmit = function (event) {
+ var data = event.rf.data;
+ RichFaces.log.info(jQuery("<span><b>onfilesubmit: </b>" + data.name + " " + data.state + "</span>"));
+ };
+
+ var onuploadcomplete = function (event) {
+ var data = event.rf.data;
+ var str = "";
+ RichFaces.log.info(jQuery("<b>onuploadcomplete:</b>"));
+ for (var i in data) {
+ var item = data[i];
+ RichFaces.log.info(" " + item.name + " " + item.state);
+ }
+ };
+ //-->
+ </script>
+ <fu:fileUpload id="fu" acceptedTypes="#{fileUploadBean.acceptedTypes}" enabled="#{fileUploadBean.enabled}"
+ fileUploadListener="#{fileUploadBean.listener}" noDuplicate="#{fileUploadBean.noDuplicate}"
+ onfilesubmit="onfilesubmit(event)" onuploadcomplete="onuploadcomplete(event)"/>
+ <h:outputText value="File name:" />
+ <a4j:outputPanel ajaxRendered="true">#{fileUploadBean.item.fileName}</a4j:outputPanel>
+ <br />
+ <h:outputText value="Attribute name: "/>
+ <h:inputText id="name"/>
+ <h:outputText value="Attribute value: "/>
+ <h:inputText id="value"/>
+ <h:commandButton value="Update attribute">
+ <f:ajax render="fu" execute="name value" listener="#{fileUploadBean.updateAttribute}"/>
+ </h:commandButton>
+ <br />
+ <h:outputText value="AcceptedTypes: " />
+ <h:inputText value="#{fileUploadBean.acceptedTypes}">
+ <f:ajax render="fu"/>
+ </h:inputText>
+ <br />
+ <h:outputText value="Enabled: " />
+ <h:selectBooleanCheckbox value="#{fileUploadBean.enabled}">
+ <f:ajax render="fu"/>
+ </h:selectBooleanCheckbox>
+ <br />
+ <h:outputText value="NoDuplicate: " />
+ <h:selectBooleanCheckbox value="#{fileUploadBean.noDuplicate}">
+ <f:ajax render="fu"/>
+ </h:selectBooleanCheckbox>
+ <br />
+ <input type="submit" />
+ <a4j:log />
+ </h:form>
+ </h:body>
+</html>
Modified: trunk/examples/input-demo/src/main/webapp/templates/template.xhtml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/templates/template.xhtml 2010-12-06 15:27:17 UTC (rev 20405)
+++ trunk/examples/input-demo/src/main/webapp/templates/template.xhtml 2010-12-06 15:35:45 UTC (rev 20406)
@@ -37,6 +37,7 @@
<li><h:commandLink value="rich:inputNumberSlider" action="inputNumberSlider" /></li>
<li><h:commandLink value="rich:inputNumberSpinner" action="inputNumberSpinner" /></li>
<li><h:commandLink value="rich:autocomplete" action="autocomplete" /></li>
+ <li><h:commandLink value="rich:fileUpload" action="fileUpload" /></li>
</ul>
<h:panelGrid columns="3">
Copied: trunk/ui/input/api/src/main/java/org/richfaces/event/FileUploadListener.java (from rev 20379, trunk/ui/misc/api/src/main/java/org/richfaces/event/FileUploadListener.java)
===================================================================
--- trunk/ui/input/api/src/main/java/org/richfaces/event/FileUploadListener.java (rev 0)
+++ trunk/ui/input/api/src/main/java/org/richfaces/event/FileUploadListener.java 2010-12-06 15:35:45 UTC (rev 20406)
@@ -0,0 +1,29 @@
+/**
+ * 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.event;
+
+import javax.faces.event.FacesListener;
+
+public interface FileUploadListener extends FacesListener {
+
+ public void processUpload(UploadEvent event);
+}
Copied: trunk/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java (from rev 20379, trunk/ui/misc/api/src/main/java/org/richfaces/event/UploadEvent.java)
===================================================================
--- trunk/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java (rev 0)
+++ trunk/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java 2010-12-06 15:35:45 UTC (rev 20406)
@@ -0,0 +1,80 @@
+/**
+ * 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.event;
+
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+import org.richfaces.model.UploadItem;
+
+public class UploadEvent extends FacesEvent {
+
+ private static final long serialVersionUID = -7645197191376210068L;
+ private List<UploadItem> uploadItems = null;
+
+ public UploadEvent(UIComponent component, List<UploadItem> uploadItems) {
+ super(component);
+ this.uploadItems = uploadItems;
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof FileUploadListener;
+ }
+
+ public void processListener(FacesListener listener) {
+ ((FileUploadListener) listener).processUpload(this);
+ }
+
+ /**
+ * Returns UploadItem instance. Returns first element of list of UploadItems in case of multiple upload.
+ *
+ * @return the uploadItem
+ */
+ public UploadItem getUploadItem() {
+ if (uploadItems != null && uploadItems.size() > 0) {
+ return uploadItems.get(0);
+ }
+ return null;
+ }
+
+ /**
+ * Return list of UploadItems
+ *
+ * @return the uploadItem
+ * @since 3.2.2
+ */
+ public List<UploadItem> getUploadItems() {
+ return uploadItems;
+ }
+
+ /**
+ * Return true if multiple files were uploaded with form
+ *
+ * @return boolean
+ * @since 3.2.2
+ */
+ public boolean isMultiUpload() {
+ return uploadItems != null && uploadItems.size() > 1;
+ }
+}
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java (from rev 20389, trunk/ui/misc/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java)
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java (rev 0)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java 2010-12-06 15:35:45 UTC (rev 20406)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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;
+
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ComponentSystemEvent;
+import javax.faces.event.ListenerFor;
+import javax.faces.event.PostAddToViewEvent;
+
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.context.FileUploadPartialViewContextFactory;
+import org.richfaces.event.FileUploadListener;
+import org.richfaces.request.MultipartRequest;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+@JsfComponent(tag = @Tag(handler = "org.richfaces.view.facelets.FileUploadHandler"),
+ renderer = @JsfRenderer(type = "org.richfaces.FileUploadRenderer"),
+ attributes = {"events-props.xml", "core-props.xml", "i18n-props.xml"})
+@ListenerFor(systemEventClass = PostAddToViewEvent.class)
+public abstract class AbstractFileUpload extends UIComponentBase {
+
+ @Attribute
+ public abstract String getAcceptedTypes();
+
+ @Attribute(defaultValue = "true")
+ public abstract boolean isEnabled();
+
+ @Attribute(defaultValue = "false")
+ public abstract boolean isNoDuplicate();
+
+ @Attribute(events = @EventName("filesubmit"))
+ public abstract String getOnfilesubmit();
+
+ @Attribute(events = @EventName("uploadcomplete"))
+ public abstract String getOnuploadcomplete();
+
+ @Override
+ public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
+ super.processEvent(event);
+ FacesContext context = getFacesContext();
+ Map<String, UIComponent> facets = getFacets();
+ UIComponent component = facets.get("progress");
+ if (component == null) {
+ try {
+ component = context.getApplication().createComponent(context, "org.richfaces.ProgressBar",
+ "org.richfaces.ProgressBarRenderer");
+ } catch (FacesException e) {
+ // To work without ProgressBar.
+ }
+ if (component != null) {
+ component.setId(getId() + "_pb");
+ facets.put("progress", component);
+ }
+ }
+ if (component != null) {
+ component.setValueExpression("value", context.getApplication().getExpressionFactory()
+ .createValueExpression(context.getELContext(),
+ "#{" + MultipartRequest.PERCENT_BEAN_NAME + "[param['"
+ + FileUploadPartialViewContextFactory.UID_KEY + "']]}", Integer.class));
+ }
+ }
+
+ /**
+ * <p>Add a new {@link FileUploadListener} to the set of listeners
+ * interested in being notified when {@link UploadEvent}s occur.</p>
+ *
+ * @param listener The {@link FileUploadListener} to be added
+ * @throws NullPointerException if <code>listener</code>
+ * is <code>null</code>
+ */
+ public void addFileUploadListener(FileUploadListener listener) {
+ addFacesListener(listener);
+ }
+
+ /**
+ * <p>Return the set of registered {@link FileUploadListener}s for this
+ * {@link AbstractFileUpload} instance. If there are no registered listeners,
+ * a zero-length array is returned.</p>
+ */
+ public FileUploadListener[] getFileUploadListeners() {
+ return (FileUploadListener[]) getFacesListeners(FileUploadListener.class);
+ }
+
+ /**
+ * <p>Remove an existing {@link FileUploadListener} (if any) from the
+ * set of listeners interested in being notified when
+ * {@link FileUploadListener}s occur.</p>
+ *
+ * @param listener The {@link FileUploadListener} to be removed
+ * @throws NullPointerException if <code>listener</code>
+ * is <code>null</code>
+ */
+ public void removeFileUploadListener(FileUploadListener listener) {
+ removeFacesListener(listener);
+ }
+}
\ No newline at end of file
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/context (from rev 20389, trunk/ui/misc/ui/src/main/java/org/richfaces/context)
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/exception (from rev 20382, trunk/ui/misc/ui/src/main/java/org/richfaces/exception)
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java (from rev 20383, trunk/ui/misc/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java)
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java (rev 0)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2010-12-06 15:35:45 UTC (rev 20406)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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 javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.event.UploadEvent;
+import org.richfaces.request.MultipartRequest;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class FileUploadRendererBase extends RendererBase {
+
+ @Override
+ protected void doDecode(FacesContext context, UIComponent component) {
+ ExternalContext externalContext = context.getExternalContext();
+ Object request = externalContext.getRequest();
+ if (request instanceof MultipartRequest
+ && externalContext.getRequestParameterMap().containsKey(component.getClientId(context))) {
+ component.queueEvent(new UploadEvent(component, ((MultipartRequest) request).getUploadItems()));
+ }
+ }
+}
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/request (from rev 20386, trunk/ui/misc/ui/src/main/java/org/richfaces/request)
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/view/facelets/FileUploadHandler.java (from rev 20386, trunk/ui/misc/ui/src/main/java/org/richfaces/view/facelets/FileUploadHandler.java)
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/view/facelets/FileUploadHandler.java (rev 0)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/view/facelets/FileUploadHandler.java 2010-12-06 15:35:45 UTC (rev 20406)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.view.facelets;
+
+import javax.el.MethodExpression;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+
+import org.richfaces.component.AbstractFileUpload;
+import org.richfaces.event.FileUploadListener;
+import org.richfaces.event.UploadEvent;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class FileUploadHandler extends ComponentHandler {
+
+ public FileUploadHandler(ComponentConfig config) {
+ super(config);
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset metaRuleset = super.createMetaRuleset(type);
+ metaRuleset.addRule(new MetaRule() {
+ @Override
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(AbstractFileUpload.class)) {
+ if ("fileUploadListener".equals(name)) {
+ return new MethodMetadata(attribute, UploadEvent.class) {
+ @Override
+ public void applyMetadata(final FaceletContext ctx, Object instance) {
+ final MethodExpression expression = getMethodExpression(ctx);
+ ((AbstractFileUpload) instance).addFileUploadListener(new FileUploadListener(){
+ public void processUpload(UploadEvent event) {
+ expression.invoke(ctx.getFacesContext().getELContext(), new Object[] {event});
+ }
+ });
+ }
+ };
+ }
+ }
+ return null;
+ }
+ });
+ return metaRuleset;
+ }
+}
Copied: trunk/ui/input/ui/src/main/resources/META-INF/fileupload.faces-config.xml (from rev 20386, trunk/ui/misc/ui/src/main/resources/META-INF/fileupload.faces-config.xml)
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/fileupload.faces-config.xml (rev 0)
+++ trunk/ui/input/ui/src/main/resources/META-INF/fileupload.faces-config.xml 2010-12-06 15:35:45 UTC (rev 20406)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, 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.
+-->
+<faces-config version="2.0"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <factory>
+ <partial-view-context-factory>org.richfaces.context.FileUploadPartialViewContextFactory</partial-view-context-factory>
+ </factory>
+</faces-config>
Copied: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss (from rev 20386, trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss)
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss (rev 0)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss 2010-12-06 15:35:45 UTC (rev 20406)
@@ -0,0 +1,176 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.
+ */
+.rf-fu {
+ background: '#{richSkin.generalBackgroundColor}';
+ border-color: '#{richSkin.panelBorderColor}';
+ border-style: solid;
+ border-width: 1px;
+ width: 400px; /*TODO Remove it*/
+}
+
+.rf-fu-hdr {
+ background-color: '#{richSkin.headerBackgroundColor}';
+ background-image: url("#{resource['org.richfaces.renderkit.html.GradientA']}");
+ border-color: '#{richSkin.headerBackgroundColor}';
+ border-style: solid;
+ border-width: 1px;
+ margin-left: 1px;
+ margin-top: 1px;
+ white-space: nowrap;
+}
+
+.rf-fu-lst {
+ height: 210px; /*TODO Remove it*/
+ overflow-x: hidden;
+ overflow-y: auto;
+}
+
+.rf-fu-cntr-hdn {
+ display: none;
+}
+
+.rf-fu-btns-lft, .rf-fu-btns-rgh, .rf-fu-itm-lft, .rf-fu-itm-rgh {
+ display: inline-block;
+ overflow: hidden;
+}
+
+.rf-fu-btns-lft {
+ width: 66%;
+}
+
+.rf-fu-btns-rgh {
+ text-align: right;
+ width: 34%;
+}
+
+.rf-fu-btn-add, .rf-fu-btn-add-dis, .rf-fu-btn-upl, .rf-fu-btn-clr {
+ background-position:left top;
+ background-repeat:repeat-x;
+ border-style: solid;
+ border-width: 1px;
+ cursor: default;
+ display: inline-block;
+ margin: 4px;
+ vertical-align: top;
+}
+
+.rf-fu-btn-add, .rf-fu-btn-upl, .rf-fu-btn-clr {
+ background-color: '#{richSkin.trimColor}';
+ background-image: url("#{resource['org.richfaces.images:fuBtnGrad.png']}");
+ border-color: '#{richSkin.panelBorderColor}';
+}
+
+.rf-fu-btn-add-dis {
+ background-color: '#{richSkin.tableFooterBackgroundColor}';
+ background-image: url("#{resource['org.richfaces.images:fuBtnDisGrad.png']}");
+ border-color: '#{richSkin.tableFooterBackgroundColor}';
+}
+
+.rf-fu-btn-upl, .rf-fu-btn-clr {
+ display: none;
+}
+
+.rf-fu-btn-cnt-add, .rf-fu-btn-cnt-add-dis, .rf-fu-btn-cnt-upl, .rf-fu-btn-cnt-clr, .rf-fu-itm-lbl, .rf-fu-itm-st, .rf-fu-itm-lnk {
+ font-family: '#{richSkin.generalFamilyFont}';
+ font-size: '#{richSkin.generalSizeFont}';
+}
+
+.rf-fu-btn-cnt-add, .rf-fu-btn-cnt-upl, .rf-fu-btn-cnt-clr, .rf-fu-itm-lbl, .rf-fu-itm-st {
+ color: '#{richSkin.generalTextColor}';
+}
+
+.rf-fu-btn-cnt-add, .rf-fu-btn-cnt-add-dis, .rf-fu-btn-cnt-upl, .rf-fu-btn-cnt-clr {
+ background-position: 2px 2px;
+ background-repeat: no-repeat;
+ display: inline-block;
+ padding: 3px 5px 3px 21px;
+}
+
+.rf-fu-btn-cnt-add {
+ background-image: url("#{resource['org.richfaces:fu-add.gif']}");
+ overflow: hidden;
+ position: relative;
+}
+
+.rf-fu-btn-cnt-add-dis {
+ background-image: url("#{resource['org.richfaces:fu-add-dis.gif']}");
+ color: '#{richSkin.tabDisabledTextColor}';
+}
+
+.rf-fu-btn-cnt-upl, .rf-fu-itm-st {
+ font-weight: bold;
+}
+
+.rf-fu-btn-cnt-upl {
+ background-image: url("#{resource['org.richfaces:fu-upl.gif']}");
+}
+
+.rf-fu-btn-cnt-clr {
+ background-image: url("#{resource['org.richfaces:fu-clr.gif']}");
+}
+
+.rf-fu-inp-cntr {
+ display: block;
+ height: 1px;
+ position: absolute;
+ right: 0;
+ top: 0;
+}
+
+.rf-fu-inp {
+ filter: "alpha(opacity=0)";
+ font-size: 10em;
+ margin: 0;
+ opacity: 0;
+ position: absolute;
+ right: 0;
+ top: 0;
+}
+
+.rf-fu-itm {
+ border-bottom-color: '#{richSkin.panelBorderColor}';
+ border-bottom-style: solid;
+ border-bottom-width: 1px;
+ padding: 12px;
+ white-space: nowrap;
+}
+
+.rf-fu-itm-lft, .rf-fu-itm-rgh {
+ vertical-align: middle;
+}
+
+.rf-fu-itm-lft {
+ width: 85%;
+}
+
+.rf-fu-itm-rgh {
+ width: 14%;
+}
+
+.rf-fu-itm-lnk {
+ color: '#{richSkin.generalLinkColor}';
+}
+
+.rf-fu-itm-st {
+ display: none;
+ margin-top: 5px;
+}
\ No newline at end of file
Copied: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js (from rev 20386, trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js)
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js (rev 0)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js 2010-12-06 15:35:45 UTC (rev 20406)
@@ -0,0 +1,274 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.
+ */
+(function(richfaces, jQuery) {
+
+ var UID = "rf_fu_uid";
+
+ var ITEM_HTML = '<div class="rf-fu-itm">'
+ + '<span class="rf-fu-itm-lft"><span class="rf-fu-itm-lbl"/><span class="rf-fu-itm-st"/></span>'
+ + '<span class="rf-fu-itm-rgh"><a href="javascript:void(0)" class="rf-fu-itm-lnk"/></span></div>';
+
+ var ITEM_STATE = {
+ NEW: "new",
+ UPLOADING: "uploading",
+ DONE: "done",
+ SIZE_EXCEEDED: "sizeExceeded",
+ STOPPED: "stopped",
+ SERVER_ERROR: "serverError"
+ };
+
+ var pressButton = function(event) {
+ jQuery(this).children(":first").css("background-position", "3px 3px").css("padding", "4px 4px 2px 22px");
+ };
+
+ var unpressButton = function(event) {
+ jQuery(this).children(":first").css("background-position", "2px 2px").css("padding", "3px 5px 3px 21px");
+ };
+
+ richfaces.ui = richfaces.ui || {};
+
+ richfaces.ui.FileUpload = richfaces.BaseComponent.extendClass({
+
+ name: "FileUpload",
+
+ items: [],
+ submitedItems: [],
+
+ doneLabel: "Done",
+ sizeExceededLabel: "File size is exceeded",
+ stoppedLabel: "",
+ serverErrorLabel: "Server error",
+ clearLabel: "Clear",
+ deleteLabel: "Delete",
+
+ init: function(id, options) {
+ this.id = id;
+ jQuery.extend(this, options);
+ if (this.acceptedTypes) {
+ this.acceptedTypes = jQuery.trim(this.acceptedTypes).split(/\s*,\s*/);
+ }
+ this.element = jQuery(this.attachToDom());
+ this.form = this.element.parents("form:first");
+ var header = this.element.children(".rf-fu-hdr:first");
+ var leftButtons = header.children(".rf-fu-btns-lft:first");
+ this.addButton = leftButtons.children(".rf-fu-btn-add:first");
+ this.uploadButton = this.addButton.next();
+ this.clearButton = leftButtons.next().children(".rf-fu-btn-clr:first");
+ this.inputContainer = this.addButton.find(".rf-fu-inp-cntr:first");
+ this.input = this.inputContainer.children("input");
+ this.list = header.next();
+ this.hiddenContainer = this.list.next();
+ this.iframe = this.hiddenContainer.children("iframe:first");
+ this.progressBarElement = this.iframe.next();
+ this.progressBar = richfaces.$(this.progressBarElement);
+ this.cleanInput = this.input.clone();
+ this.addProxy = jQuery.proxy(this.__addItem, this);
+ this.input.change(this.addProxy);
+ this.addButton.mousedown(pressButton).mouseup(unpressButton).mouseout(unpressButton);
+ this.uploadButton.click(jQuery.proxy(this.__startUpload, this)).mousedown(pressButton)
+ .mouseup(unpressButton).mouseout(unpressButton);
+ this.clearButton.click(jQuery.proxy(this.__removeAllItems, this)).mousedown(pressButton)
+ .mouseup(unpressButton).mouseout(unpressButton);
+ this.iframe.load(jQuery.proxy(this.__load, this));
+ if (this.onfilesubmit) {
+ richfaces.Event.bind(this.element, "onfilesubmit", new Function("event", this.onfilesubmit));
+ }
+ if (this.onuploadcomplete) {
+ richfaces.Event.bind(this.element, "onuploadcomplete", new Function("event", this.onuploadcomplete));
+ }
+ },
+
+ __addItem: function() {
+ var fileName = this.input.val();
+ if (this.__accept(fileName) && (!this.noDuplicate || !this.__isFileAlreadyAdded(fileName))) {
+ this.input.hide();
+ this.input.unbind("change", this.addProxy);
+ var item = new Item(this);
+ this.list.append(item.getJQuery());
+ this.items.push(item);
+ this.input = this.cleanInput.clone();
+ this.inputContainer.append(this.input);
+ this.input.change(this.addProxy);
+ this.__updateButtons();
+ }
+ },
+
+ __removeItem: function(item) {
+ this.items.splice(this.items.indexOf(item), 1);
+ this.submitedItems.splice(this.submitedItems.indexOf(item), 1);
+ this.__updateButtons();
+ },
+
+ __removeAllItems: function(item) {
+ this.inputContainer.children(":not(:visible)").remove();
+ this.list.empty();
+ this.items.splice(0);
+ this.submitedItems.splice(0);
+ this.__updateButtons();
+ },
+
+ __updateButtons: function() {
+ if (!this.loadableItem && this.list.children(".rf-fu-itm").size()) {
+ if (this.items.length) {
+ this.uploadButton.css("display", "inline-block");
+ } else {
+ this.uploadButton.hide();
+ }
+ this.clearButton.css("display", "inline-block");
+ } else {
+ this.uploadButton.hide();
+ this.clearButton.hide();
+ }
+ },
+
+ __startUpload: function() {
+ this.loadableItem = this.items.shift();
+ this.__updateButtons();
+ this.loadableItem.startUploading();
+ },
+
+ __submit: function() {
+ var originalAction = this.form.attr("action");
+ var originalEncoding = this.form.attr("encoding");
+ var originalEnctype = this.form.attr("enctype");
+ try {
+ this.form.attr("action", originalAction + "?" + UID + "=" + this.loadableItem.uid);
+ this.form.attr("encoding", "multipart/form-data");
+ this.form.attr("enctype", "multipart/form-data");
+ richfaces.submitForm(this.form, {"org.richfaces.ajax.component": this.id}, this.id);
+ richfaces.Event.fire(this.element, "onfilesubmit", this.loadableItem.model);
+ } finally {
+ this.form.attr("action", originalAction);
+ this.form.attr("encoding", originalEncoding);
+ this.form.attr("enctype", originalEnctype);
+ this.loadableItem.input.removeAttr("name");
+ }
+ },
+
+ __load: function(event) {
+ if (this.loadableItem) {
+ var contentDocument = event.target.contentWindow.document;
+ contentDocument = contentDocument.XMLDocument || contentDocument;
+ var documentElement = contentDocument.documentElement;
+ var responseStatus, id;
+ if (documentElement.tagName.toUpperCase() == "PARTIAL-RESPONSE") {
+ responseStatus = ITEM_STATE.DONE;
+ } else if ((id = documentElement.id) && id.indexOf(UID + this.loadableItem.uid + ":") == 0) {
+ responseStatus = id.split(":")[1];
+ }
+ if (responseStatus) {
+ responseStatus == ITEM_STATE.DONE && jsf.ajax.response({responseXML: contentDocument}, {});
+ this.loadableItem.finishUploading(responseStatus);
+ this.submitedItems.push(this.loadableItem);
+ if (responseStatus == ITEM_STATE.DONE && this.items.length) {
+ this.__startUpload();
+ } else {
+ this.loadableItem = null;
+ this.__updateButtons();
+ var items = [];
+ for (var i in this.submitedItems) {
+ items.push(this.submitedItems[i].model);
+ }
+ for (var i in this.items) {
+ items.push(this.items[i].model);
+ }
+ richfaces.Event.fire(this.element, "onuploadcomplete", items);
+ }
+ }
+ }
+ },
+
+ __accept: function(fileName) {
+ var result = !this.acceptedTypes;
+ for (var i = 0; !result && i < this.acceptedTypes.length; i++) {
+ var extension = this.acceptedTypes[i];
+ result = fileName.indexOf(extension, fileName.length - extension.length) !== -1;
+ }
+ return result;
+ },
+
+ __isFileAlreadyAdded: function(fileName) {
+ var result = false;
+ for (var i = 0; !result && i < this.items.length; i++) {
+ result = this.items[i].model.name == fileName;
+ }
+ result = result || (this.loadableItem && this.loadableItem.model.name == fileName);
+ for (var i = 0; !result && i < this.submitedItems.length; i++) {
+ result = this.submitedItems[i].model.name == fileName;
+ }
+ return result;
+ }
+ });
+
+ var Item = function(fileUpload) {
+ this.fileUpload = fileUpload;
+ this.input = fileUpload.input;
+ this.model = {name: this.input.val(), state: ITEM_STATE.NEW};
+ };
+
+ jQuery.extend(Item.prototype, {
+ getJQuery: function() {
+ this.element = jQuery(ITEM_HTML);
+ var leftArea = this.element.children(".rf-fu-itm-lft:first");
+ this.label = leftArea.children(".rf-fu-itm-lbl:first");
+ this.state = this.label.nextAll(".rf-fu-itm-st:first");
+ this.link = leftArea.next().children("a");
+ this.label.html(this.model.name);
+ this.link.html(this.fileUpload["deleteLabel"]);
+ this.link.click(jQuery.proxy(this.removeOrStop, this));
+ return this.element;
+ },
+
+ removeOrStop: function() {
+ this.input.remove();
+ this.element.remove();
+ this.fileUpload.__removeItem(this);
+ },
+
+ startUploading: function() {
+ this.state.css("display", "block");
+ this.link.html("");
+ this.input.attr("name", this.fileUpload.id);
+ this.model.state = ITEM_STATE.UPLOADING;
+ this.uid = Math.random();
+ this.fileUpload.__submit();
+ var params = {};
+ params[UID] = this.uid;
+ if (this.fileUpload.progressBar) {
+ this.fileUpload.progressBar.setValue(0);
+ this.state.html(this.fileUpload.progressBarElement.detach());
+ this.fileUpload.progressBar.enable(params);
+ }
+ },
+
+ finishUploading: function(state) {
+ if (this.fileUpload.progressBar) {
+ this.fileUpload.progressBar.disable();
+ this.fileUpload.hiddenContainer.append(this.fileUpload.progressBarElement.detach());
+ }
+ this.input.remove();
+ this.state.html(this.fileUpload[state + "Label"]);
+ this.link.html(this.fileUpload["clearLabel"]);
+ this.model.state = state;
+ }
+ });
+}(window.RichFaces, jQuery));
Copied: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-add-dis.gif (from rev 20386, trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fu-add-dis.gif)
===================================================================
(Binary files differ)
Copied: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-add.gif (from rev 20386, trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fu-add.gif)
===================================================================
(Binary files differ)
Copied: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-clr.gif (from rev 20386, trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fu-clr.gif)
===================================================================
(Binary files differ)
Copied: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-upl.gif (from rev 20386, trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/fu-upl.gif)
===================================================================
(Binary files differ)
Modified: trunk/ui/input/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties 2010-12-06 15:27:17 UTC (rev 20405)
+++ trunk/ui/input/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties 2010-12-06 15:35:45 UTC (rev 20406)
@@ -10,4 +10,8 @@
org.richfaces.images\:inplaceBtnPressGrad.png=org.richfaces.renderkit.html.BaseGradient\
{width=8, height=18, baseColorParam=tabBackgroundColor, gradientColorParam=generalBackgroundColor}
org.richfaces.images\:insldrTrackGrad.png=org.richfaces.renderkit.html.BaseGradient\
- {width=7, height=10, gradientHeight=7, baseColorParam=tabBackgroundColor, gradientColorParam=controlBackgroundColor}
\ No newline at end of file
+ {width=7, height=10, gradientHeight=7, baseColorParam=tabBackgroundColor, gradientColorParam=controlBackgroundColor}
+org.richfaces.images\:fuBtnGrad.png=org.richfaces.renderkit.html.BaseGradient\
+ {baseColorParam=additionalBackgroundColor, gradientColorParam=trimColor, height=18, width=1}
+org.richfaces.images\:fuBtnDisGrad.png=org.richfaces.renderkit.html.BaseGradient\
+ {baseColorParam=tableSubfooterBackgroundColor, gradientColorParam=tableFooterBackgroundColor, height=18, width=1}
\ No newline at end of file
Copied: trunk/ui/input/ui/src/main/templates/fileupload.template.xml (from rev 20384, trunk/ui/misc/ui/src/main/templates/fileupload.template.xml)
===================================================================
--- trunk/ui/input/ui/src/main/templates/fileupload.template.xml (rev 0)
+++ trunk/ui/input/ui/src/main/templates/fileupload.template.xml 2010-12-06 15:35:45 UTC (rev 20406)
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, 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.
+-->
+<cdk:root xmlns="http://jboss.org/schema/richfaces/cdk/xhtml-el" xmlns:cdk="http://jboss.org/schema/richfaces/cdk/core"
+ xmlns:cc="http://jboss.org/schema/richfaces/cdk/jsf/composite" xmlns:c="http://jboss.org/schema/richfaces/cdk/jstl/core"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <cc:interface>
+ <cdk:class>org.richfaces.renderkit.html.FileUploadRenderer</cdk:class>
+ <cdk:superclass>org.richfaces.renderkit.FileUploadRendererBase</cdk:superclass>
+ <cdk:component-family>org.richfaces.FileUpload</cdk:component-family>
+ <cdk:renderer-type>org.richfaces.FileUploadRenderer</cdk:renderer-type>
+ <cdk:resource-dependency library="org.richfaces" name="fileupload.ecss" />
+ <cdk:resource-dependency library="org.richfaces" name="ajax.reslib" />
+ <cdk:resource-dependency library="org.richfaces" name="base-component.reslib" />
+ <cdk:resource-dependency name="richfaces-event.js" />
+ <cdk:resource-dependency library="org.richfaces" name="fileupload.js" />
+ </cc:interface>
+ <cc:implementation>
+ <cdk:object name="attributes" value="#{component.attributes}"/>
+ <cdk:object name="enabled" value="#{attributes['enabled']}"/>
+ <div id="#{clientId}" class="rf-fu #{attributes['styleClass']}"
+ cdk:passThroughWithExclusions="">
+ <div class="rf-fu-hdr">
+ <span class="rf-fu-btns-lft">
+ <span class="rf-fu-btn-add#{enabled ? '' : '-dis'}">
+ <span class="rf-fu-btn-cnt-add#{enabled ? '' : '-dis'}">
+ <c:if test="#{enabled}">
+ <span class="rf-fu-inp-cntr"> <!-- This span is needed for IE7 only. -->
+ <input type="file" class="rf-fu-inp"/>
+ </span>
+ </c:if>
+ <cdk:object name="addLabel" value="#{attributes['addLabel']}"/>
+ #{addLabel != null ? addLabel : 'Add...'}
+ </span>
+ </span>
+ <c:if test="#{enabled}">
+ <span class="rf-fu-btn-upl">
+ <cdk:object name="uploadLabel" value="#{attributes['uploadLabel']}"/>
+ <span class="rf-fu-btn-cnt-upl">#{uploadLabel != null ? uploadLabel : 'Upload'}</span>
+ </span>
+ </c:if>
+ </span>
+ <c:if test="#{enabled}">
+ <span class="rf-fu-btns-rgh">
+ <span class="rf-fu-btn-clr">
+ <cdk:object name="clearAllLabel" value="#{attributes['clearAllLabel']}"/>
+ <span class="rf-fu-btn-cnt-clr">#{clearAllLabel != null ? clearAllLabel : 'Clear All'}</span>
+ </span>
+ </span>
+ </c:if>
+ </div>
+ <div class="rf-fu-lst"/>
+ <c:if test="#{enabled}">
+ <div class="rf-fu-cntr-hdn">
+ <iframe name="#{clientId}"/>
+ <cdk:object name="progressBar" value="#{component.facets['progress']}"/>
+ <c:if test="#{progressBar != null and progressBar.isRendered()}">
+ <cdk:call expression="progressBar.encodeAll(facesContext)" />
+ </c:if>
+ </div>
+ <cdk:scriptObject name="options">
+ <cdk:scriptOption attributes="acceptedTypes noDuplicate onfilesubmit onuploadcomplete doneLabel
+ sizeExceededLabel stoppedLabel serverErrorLabel clearLabel deleteLabel"/>
+ </cdk:scriptObject>
+ <script type="text/javascript">new RichFaces.ui.FileUpload(#{toScriptArgs(clientId, options)});</script>
+ </c:if>
+ </div>
+ </cc:implementation>
+</cdk:root>
14 years, 1 month
JBoss Rich Faces SVN: r20405 - in trunk/examples/richfaces-showcase/src/main/webapp/richfaces: panelMenu/samples and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2010-12-06 10:27:17 -0500 (Mon, 06 Dec 2010)
New Revision: 20405
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/panelMenu.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/togglePanel/samples/simple-sample.xhtml
Log:
panelMenu samples finished.
Modified: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/panelMenu.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/panelMenu.xhtml 2010-12-06 14:11:23 UTC (rev 20404)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/panelMenu.xhtml 2010-12-06 15:27:17 UTC (rev 20405)
@@ -17,6 +17,10 @@
<ui:param name="openLabel" value="View Source" />
<ui:param name="hideLabel" value="Hide Source" />
</ui:include>
+ <p>That menu uses parent component <b>itemChangeListener</b> to
+ output current selection but you could use <b>action/actionListener</b>
+ pair at <b>panelMenuItem</b>'s as usually to perform navigation and
+ process ActionEvent from them</p>
<p>Switching mode could be chosen with the <b>itemMode</b>
attribute for all panelMenu items except ones where this attribute was
redefined.</p>
Modified: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml 2010-12-06 14:11:23 UTC (rev 20404)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml 2010-12-06 15:27:17 UTC (rev 20405)
@@ -12,64 +12,38 @@
</style>
<h:form id="form">
<h:panelGrid columns="2" columnClasses="cols,cols" width="400">
- <rich:panelMenu style="width:200px" mode="ajax"
+ <rich:panelMenu style="width:200px" mode="ajax" groupMode="ajax"
iconExpandedGroup="disc" iconCollapsedGroup="disc"
- iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
+ iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
iconCollapsedTopGroup="chevronDown"
- activeItem="#{panelMenuBean.current}">
+ itemChangeListener="#{panelMenuBean.updateCurrent}">
<rich:panelMenuGroup label="Group 1">
- <rich:panelMenuItem label="Item 1.1">
- <f:param name="current" value="Item 1.1" />
- </rich:panelMenuItem>
- <rich:panelMenuItem label="Item 1.2">
- <f:param name="current" value="Item 1.2" />
- </rich:panelMenuItem>
- <rich:panelMenuItem label="Item 1.3">
- <f:param name="current" value="Item 1.3" />
- </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 1.1" name="Item_1_1"/>
+ <rich:panelMenuItem label="Item 1.2" name="Item_1_2"/>
+ <rich:panelMenuItem label="Item 1.3" name="Item_1_3"/>
</rich:panelMenuGroup>
<rich:panelMenuGroup label="Group 2">
- <rich:panelMenuItem label="Item 2.1">
- <f:param name="current" value="Item 2.1" />
- </rich:panelMenuItem>
- <rich:panelMenuItem label="Item 2.2">
- <f:param name="current" value="Item 2.2" />
- </rich:panelMenuItem>
- <rich:panelMenuItem label="Item 2.3">
- <f:param name="current" value="Item 2.3" />
- </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 2.1" name="Item_2_1"/>
+ <rich:panelMenuItem label="Item 2.2" name="Item_2_2"/>
+ <rich:panelMenuItem label="Item 2.3" name="Item_2_3"/>
<rich:panelMenuGroup label="Group 2.4">
- <rich:panelMenuItem label="Item 2.4.1">
- <f:param name="current" value="Item 2.4.1" />
- </rich:panelMenuItem>
- <rich:panelMenuItem label="Item 2.4.2">
- <f:param name="current" value="Item 2.4.2" />
- </rich:panelMenuItem>
- <rich:panelMenuItem label="Item 2.4.3">
- <f:param name="current" value="Item 2.4.3" />
- </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 2.4.1" name="Item_2_4_1"/>
+ <rich:panelMenuItem label="Item 2.4.2" name="Item_2_4_2"/>
+ <rich:panelMenuItem label="Item 2.4.3" name="Item_2_4_3"/>
</rich:panelMenuGroup>
- <rich:panelMenuItem label="Item 2.5">
- <f:param name="current" value="Item 2.5" />
- </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 2.5" name="Item_2_5"/>
</rich:panelMenuGroup>
<rich:panelMenuGroup label="Group 3">
- <rich:panelMenuItem label="Item 3.1">
- <f:param name="current" value="Item 3.1" />
- </rich:panelMenuItem>
- <rich:panelMenuItem label="Item 3.2">
- <f:param name="current" value="Item 3.2" />
- </rich:panelMenuItem>
- <rich:panelMenuItem label="Item 3.3">
- <f:param name="current" value="Item 3.3" />
- </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 3.1" name="Item_3_1"/>
+ <rich:panelMenuItem label="Item 3.2" name="Item_3_2"/>
+ <rich:panelMenuItem label="Item 3.3" name="Item_3_3"/>
</rich:panelMenuGroup>
</rich:panelMenu>
- <rich:panel bodyClass="rich-laguna-panel-no-header">
<a4j:outputPanel ajaxRendered="true">
+ <rich:panel rendered="#{not empty panelMenuBean.current}">
<h:outputText value="#{panelMenuBean.current} selected" id="current" />
- </a4j:outputPanel>
</rich:panel>
+ </a4j:outputPanel>
</h:panelGrid>
</h:form>
</ui:composition>
\ No newline at end of file
Modified: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/togglePanel/samples/simple-sample.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/togglePanel/samples/simple-sample.xhtml 2010-12-06 14:11:23 UTC (rev 20404)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/togglePanel/samples/simple-sample.xhtml 2010-12-06 15:27:17 UTC (rev 20405)
@@ -19,7 +19,7 @@
}
</style>
<h:form>
- <rich:togglePanel id="panel1" activeItem="item1" render="tabs">
+ <rich:togglePanel id="panel1" activeItem="item1" render="tabs" itemChangeListener="#{panelMenuBean.updateCurrent}">
<rich:togglePanelItem name="item1">
<p>This toggle panel switches in Ajax mode. So only one active
item loaded to the client.</p>
14 years, 1 month