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