Author: konstantin.mishin
Date: 2010-12-03 15:41:52 -0500 (Fri, 03 Dec 2010)
New Revision: 20389
Added:
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/ui/src/main/java/org/richfaces/context/
Removed:
trunk/ui/misc/ui/src/main/java/org/richfaces/cotext/
Modified:
trunk/examples/misc-demo/pom.xml
trunk/examples/misc-demo/src/main/webapp/WEB-INF/web.xml
trunk/ui/misc/api/pom.xml
trunk/ui/misc/ui/pom.xml
trunk/ui/misc/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java
Log:
RF-9921
Modified: trunk/examples/misc-demo/pom.xml
===================================================================
--- trunk/examples/misc-demo/pom.xml 2010-12-03 20:34:04 UTC (rev 20388)
+++ trunk/examples/misc-demo/pom.xml 2010-12-03 20:41:52 UTC (rev 20389)
@@ -47,6 +47,10 @@
<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>
Copied: trunk/examples/misc-demo/src/main/java/org/richfaces/demo/FileUploadBean.java
(from rev 20280,
sandbox/trunk/examples/fileupload-demo/src/main/java/org/richfaces/demo/FileUploadBean.java)
===================================================================
--- trunk/examples/misc-demo/src/main/java/org/richfaces/demo/FileUploadBean.java
(rev 0)
+++
trunk/examples/misc-demo/src/main/java/org/richfaces/demo/FileUploadBean.java 2010-12-03
20:41:52 UTC (rev 20389)
@@ -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);
+ }
+}
Copied: trunk/examples/misc-demo/src/main/java/org/richfaces/demo/SkinBean.java (from rev
20241,
sandbox/trunk/examples/fileupload-demo/src/main/java/org/richfaces/demo/SkinBean.java)
===================================================================
--- trunk/examples/misc-demo/src/main/java/org/richfaces/demo/SkinBean.java
(rev 0)
+++ trunk/examples/misc-demo/src/main/java/org/richfaces/demo/SkinBean.java 2010-12-03
20:41:52 UTC (rev 20389)
@@ -0,0 +1,29 @@
+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-03 20:34:04 UTC (rev
20388)
+++ trunk/examples/misc-demo/src/main/webapp/WEB-INF/web.xml 2010-12-03 20:41:52 UTC (rev
20389)
@@ -4,6 +4,15 @@
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>
Copied: trunk/examples/misc-demo/src/main/webapp/pages/fileupload.xhtml (from rev 20280,
sandbox/trunk/examples/fileupload-demo/src/main/webapp/fileupload.xhtml)
===================================================================
--- trunk/examples/misc-demo/src/main/webapp/pages/fileupload.xhtml
(rev 0)
+++ trunk/examples/misc-demo/src/main/webapp/pages/fileupload.xhtml 2010-12-03 20:41:52
UTC (rev 20389)
@@ -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/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>
Modified: trunk/ui/misc/api/pom.xml
===================================================================
--- trunk/ui/misc/api/pom.xml 2010-12-03 20:34:04 UTC (rev 20388)
+++ trunk/ui/misc/api/pom.xml 2010-12-03 20:41:52 UTC (rev 20389)
@@ -27,19 +27,16 @@
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-ui-parent</artifactId>
<version>4.0.0-SNAPSHOT</version>
+ <relativePath>../../parent/pom.xml</relativePath>
</parent>
- <groupId>org.richfaces.ui.fileupload</groupId>
- <artifactId>richfaces-ui-fileupload-api</artifactId>
- <name>Richfaces UI Components: FileUpload API</name>
+ <groupId>org.richfaces.ui.misc</groupId>
+ <artifactId>richfaces-ui-misc-api</artifactId>
+ <name>Richfaces UI Components: Misc API</name>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>maven-cdk-plugin</artifactId>
- </plugin>
- <plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
</plugins>
Modified: trunk/ui/misc/ui/pom.xml
===================================================================
--- trunk/ui/misc/ui/pom.xml 2010-12-03 20:34:04 UTC (rev 20388)
+++ trunk/ui/misc/ui/pom.xml 2010-12-03 20:41:52 UTC (rev 20389)
@@ -59,6 +59,10 @@
<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>
Modified: 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-03
20:34:04 UTC (rev 20388)
+++
trunk/ui/misc/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java 2010-12-03
20:41:52 UTC (rev 20389)
@@ -23,6 +23,7 @@
import java.util.Map;
+import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;
@@ -72,8 +73,12 @@
Map<String, UIComponent> facets = getFacets();
UIComponent component = facets.get("progress");
if (component == null) {
- component = context.getApplication().createComponent(context,
"org.richfaces.ProgressBar",
- "org.richfaces.ProgressBarRenderer");
+ 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);
Copied: trunk/ui/misc/ui/src/main/java/org/richfaces/context (from rev 20382,
trunk/ui/misc/ui/src/main/java/org/richfaces/cotext)