ui:upload -

Hello,

I have this upload component on my page:

<ui:upload binding="#{insert.fileUpload1}" id="fileUpload1"

uploadedFile="#{insert.uploadedIndex}"/>

The problem is that it does not work as expected. When I try to upload

a file, nothing happens.

I have setters and getters for both fileUpload1 and uploadedIndex.

I have found out that when I choose a file and click the button, the

getUploadedIndex method is called - instead ofsetUploadedIndex.

The method returnsnull (which is correct) and then no other operations

with the file are done.

On the other hand, when I do not choose any file and click the button,

setUploadedIndex is called and then all the page (bean) code proceeds.

Does anyone know where the problem is?

[919 byte] By [honzaa] at [2007-11-27 0:44:51]
# 1
Have you read the API? http://developers.sun.com/prodtech/javatools/jscreator/reference/docs/apis/webui/com/sun/rave/web/ui/component/UploadBase.htmlIt's very descriptive, with clear examples.
BalusCa at 2007-7-11 23:09:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Yes, I have and now once again. My setter and getter methods are the same as in the API.Message was edited by: honza
honzaa at 2007-7-11 23:09:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Have you actually added the UploadFilter? Are the componentbinding accessors called anyway? Aren't you recreating the whole component on every request by componentbinding?
BalusCa at 2007-7-11 23:09:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Regarding the UploadFilter, I am developing the page in Netbeans and this was done by it.

getFileUpload1 and setFileUpload1 are called.

Yes, it is possible that is recreated on every request. I am not familiar with this component and the only manual I have found is that API page where some things are not mentioned.

I have this line in my code: private Upload fileUpload1; I have tried also private Upload fileUpload1 = new Upload();

honzaa at 2007-7-11 23:09:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
What does fileUpload1.getSize() say after submit?Anyway, if this does not return anyting, try to strictly follow the API documentation. Use the same object types, remove the binding attribute and don't instantiate the upload. Don't let it generate or so.
BalusCa at 2007-7-11 23:09:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
I do not think I need the binding attribute but Netbeans is always creating a new upload component with such binding :-(, I wanted to try it is spite of having this additional component but the page breaks down then.
honzaa at 2007-7-11 23:09:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
Just remove " = new Upload()" from the property.But doesn't fileUpload1.getSize() say something after submit? This is just to find out if the file is actually accessible by the componentbinding instead of the valuebinding.
BalusCa at 2007-7-11 23:09:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
Thank you for your patience!I recreated the upload the component and did not add the uploadedFile attribute. I access the file directly by means of the upload component now.I also removed the " = new Upload()" part of the code. And it works now.
honzaa at 2007-7-11 23:09:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...