dev@woodstock.java.net

[FileUpload] - After implenting <webuijsf:upload> no more actions are performed

From: Kadah, Feraz <Kadah.Feraz_at_gfos.de>
Date: Tue, 18 Sep 2007 16:34:37 +0200

Hello everybody, I have a problem which I'm note able fix:

 

I am using the "Woodstock 4.1 Build 12" components on "Glassfish V2 b58g". I've got three buttons positioned on the JSP which work very well until I place the FileUpload-Component on the page. After that, the actions of the buttons are not longer performed and the application is feckless.

 

I've looked at the Woodstock-Examples and tried to upload a small file but this was also unsuccessful. A path is shown in the example, but the file is not existent.

 

 

This is the code I've implemented in my application:

 

In the JSP:

 

<webuijsf:upload id="upload1" label="Choose a file: "

                 valueChangeListener="#{FileUploadedListener.processValueChange}"/>

 

 

In the BackingBean:

 

public void loadImage(ValueChangeEvent event) throws AbortProcessingException {

 

    logger.log(Level.INFO, "[loadImage] Start");

    

    Object value = event.getNewValue();

    

    if (value != null && value instanceof UploadedFile) {

      UploadedFile uploadedFile = (UploadedFile)value;

      

      String name = uploadedFile.getOriginalName();

      

      if (name == null || name.length() == 0) {

        name = "tmp.tmp";

      }

      

      String suffix = name.substring(name.indexOf("."));

      if (suffix.length() == 0) {

        suffix = ".tmp";

      }

      

      String prefix = name.substring(0, name.indexOf("."));

 

      try {

        File fileDir = new File("C:/Programme/glassfish-v2-b58g/domains/domain1/docroot/");

        File imgFile = File.createTempFile(prefix, suffix, fileDir);

        

        uploadedFile.write(imgFile);

      

      } catch (Exception noFileUpload) {

        logger.log(Level.SEVERE, "[loadImage] Fehler beim Bildupload!", noFileUpload);

      }

    }

    logger.log(Level.INFO, "[loadImage] Ende");

  }

 

 

 

Now I don't know, if I am making any mistake or if it is a bug in the Woodstock's.

I hope you can help me, because I'm already desperate... J

 

 

 

 

With best regards,

Feraz Kadah

 

G F O S mbH

Cathostraße 5 · 45356 Essen

Amtsgericht Essen, HRB 7600

Geschäftsführer: Burkhard Röhrig

 

Tel.: +49 (0)2 01 / 61 30 00

Fax: +49 (0)2 01 / 61 93 17

Kadah.Feraz_at_gfos.com <mailto:kadah.feraz_at_gfos.com>

 

<br> <br> <span style="font-size: 10pt; font-family: Arial; color: rgb(192, 0, 82); font-weight: bold;">GFOS live erleben!</span> <span style="font-size: 10pt; font-family: Arial;"><span style="font-size: 10pt; font-weight: bold;">X/TIME Anwenderforum</span>&ndash; Essen, 18.-19.09.2007, Philharmonie Essen</span> <span style="font-size: 10pt; font-family: Arial;"><span style="font-size: 10pt; font-weight: bold;">Systems</span>&ndash;M&uuml;nchen, 23.-26.10.2007, Halle A.1, Stand 212 + Stand 201.23 </span> <span style="font-size: 10pt; font-family: Arial;">Weitere Messen und News unter: <a href="http://www.gfos.com/">http://www.gfos.com/</a><br></span> ########################################### This message has been scanned by F-Secure Anti-Virus. For more information, connect to http://www.f-secure.com/