3 Replies Latest reply on Oct 2, 2008 1:16 PM by larry3k

    <rich:fileUpload> calls more listeners

    larry3k

      I have 3 <rich:fileUpload> elements on my page. I know you can upload more files with this element but I also need to know the position of each picture (for example left, right etc...), so I decided to have a <rich:fileUpload> element for each position.

      I have 2 problems:

      1. I can select an image for all three elements but I can click the upload button only for the first one. For the second and the third the upload button is there but it doesn't work.

      2. I have a different listener for each component and when I upload the file for the first component the first listener is called (so far so good) but then the second listener is also called and I get a NullPointerException.

      Here is my code:


      <h:outputText value="#{msg.text_right}" />

      <rich:fileUpload fileUploadListener="#{handler.listenerRight}" maxFilesQuantity="1" id="uploadR" listWidth="300px"
      acceptedTypes="jpg, gif, png, bmp" />

      <h:outputText value="#{msg.text_left}" />

      <rich:fileUpload fileUploadListener="#{handler.listenerLeft}"
      maxFilesQuantity="1" id="uploadL" listWidth="300px"
      acceptedTypes="jpg, gif, png, bmp" />

      <h:outputText for="file3" value="#{msg.text_center}" />

      <rich:fileUpload fileUploadListener="#{handler.listenerFront}"
      maxFilesQuantity="1" id="uploadF" listWidth="300px"
      acceptedTypes="jpg, gif, png, bmp" />



      public void listenerRight(UploadEvent event) throws IOException{
      UploadItem item = event.getUploadItem();
      InputStream picture = new ByteArrayInputStream(item.getData());
      ...
      }

      public void listenerLeft(UploadEvent event) throws IOException{
      UploadItem item = event.getUploadItem();
      InputStream picture = new ByteArrayInputStream(item.getData());
      ...
      }

      public void listenerFront(UploadEvent event) throws IOException{
      UploadItem item = event.getUploadItem();
      InputStream picture = new ByteArrayInputStream(item.getData());
      ...
      }


      thanks