Version 1

    Hi i m getting EL Exception, property not found excpetion, though i have method in my bean,

    dont understand why its failing to get property from the below method.

     

     

    public void listener(FileUploadEvent event) throws IOException {

            file = event.getUploadedFile();

        }

     

     

    Completre stack trace for the error.

     

    SEVERE: Error Rendering View[/examples/fileupload.xhtml]

    javax.el.ELException: /examples/fileupload.xhtml: Property 'listener' not found on type org.richfaces.demo.FileUploadBean

              at com.sun.faces.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:94)

              at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)

              at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)

              at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)

              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)

              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756)

              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)

              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)

              at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:401)

              at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)

              at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)

              at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)

              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)

              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)

              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)

              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

              at java.lang.Thread.run(Thread.java:662)

     

     

     

     

      xhtml and beans classes are..

     

     

    fileupload.xhtml

     


     

    <?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}"

                                                      disabled="#{fileUploadBean.disabled}"

                                                      fileUploadListener="#{fileUploadBean.listener}"

                                                      noDuplicate="#{fileUploadBean.noDuplicate}"

                                                      onfilesubmit="onfilesubmit(event)"

                                                      onuploadcomplete="onuploadcomplete(event)"/>

                                  <h:outputText value="File name:" />

                                  <a4j:outputPanel ajaxRendered="true">#{fileUploadBean.file.name}</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="Disabled: " />

                <h:selectBooleanCheckbox value="#{fileUploadBean.disabled}">

                        <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>

     

     

     

    FileUploadBean.java

     

    package org.richfaces.demo;

    import java.io.IOException;

    import java.io.OutputStream;

    import java.io.Serializable;

    import java.util.ArrayList;

     

     

    import javax.faces.bean.ManagedBean;

    import javax.faces.bean.SessionScoped;

     

     

    import org.richfaces.event.FileUploadEvent;

    import org.richfaces.model.UploadedFile;

     

     

    /**

    * @author Ilya Shaikovsky

    *

    */

    @ManagedBean

    @SessionScoped

    public class FileUploadBean implements Serializable {

     

     

               private String acceptedTypes;

               private boolean disabled = false;

                  public String getAcceptedTypes() {

                        return acceptedTypes;

              }

     

     

              public void setAcceptedTypes(String acceptedTypes) {

                        this.acceptedTypes = acceptedTypes;

              }

     

     

              public boolean isDisabled() {

                        return disabled;

              }

     

     

              public void setDisabled(boolean disabled) {

                        this.disabled = disabled;

              }

     

     

              public boolean isNoDuplicate() {

                        return noDuplicate;

              }

     

     

              public void setNoDuplicate(boolean noDuplicate) {

                        this.noDuplicate = noDuplicate;

              }

     

     

                        private boolean noDuplicate = false;

                 

        private ArrayList<UploadedImage> files = new ArrayList<UploadedImage>();

     

     

        public void paint(OutputStream stream, Object object) throws IOException {

            stream.write(getFiles().get((Integer) object).getData());

            stream.close();

        }

     

     

        public void listener(FileUploadEvent event) throws IOException {

            UploadedFile item = event.getUploadedFile();

            UploadedImage file = new UploadedImage();

            file.setLength(item.getData().length);

            file.setName(item.getName());

            file.setData(item.getData());

            files.add(file);

        }

     

     

        public String clearUploadData() {

            files.clear();

            return null;

        }

     

     

        public int getSize() {

            if (getFiles().size() > 0) {

                return getFiles().size();

            } else {

                return 0;

            }

        }

     

     

        public long getTimeStamp() {

            return System.currentTimeMillis();

        }

     

     

        public ArrayList<UploadedImage> getFiles() {

            return files;

        }

     

     

        public void setFiles(ArrayList<UploadedImage> files) {

            this.files = files;

        }

     

    }