-
1. Re: Can't get rich:fileUpload to work (using 2.0.0.A)
wesleyhales Oct 27, 2009 8:34 AM (in response to mlavannis)The multipart request is handled differently in the 2.0 world than 168, any help debugging would be great.
-
2. Re: Can't get rich:fileUpload to work (using 2.0.0.A)
stefan_tausendpfund Nov 3, 2009 10:26 AM (in response to mlavannis)Hello,
we also have problems with the fileUpload component and portletbridge. It worked well in previous versions.
The fileUploadListener is not called in portal environment.
The fileupload in richfaces demo of portletbridge does not work on my server. Does this work on your side?
I created also a small demo using this environment (created with maven)
JSF 1.2_13 (copied to server\default\deploy\jboss-web.deployer\jsf-libs)
richfaces-3.3.3-SNAPSHOT (from 02.11 - there was also some changes in multipart requests submitted this week https://jira.jboss.org/jira/browse/RF-7927) - also tested 3.3.2.SR1
portletbridge SNAPSHOT - also BETA
jbossportal 2.7.2
configration in web.xml:<filter> <display-name>Ajax4jsf Filter</display-name> <filter-name>ajax4jsf</filter-name> <filter-class>org.ajax4jsf.Filter</filter-class> <init-param> <param-name>createTempFiles</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>maxRequestSize</param-name> <param-value>100000</param-value> </init-param> </filter>
configuration in faces-config.xml:<application> <view-handler> org.jboss.portletbridge.application.PortletViewHandler</view-handler> <state-manager>org.jboss.portletbridge.application.PortletStateManager</state-manager> </application>
fileUpload.xhtml (taken from richfaces demo sample)<rich:fileUpload fileUploadListener="#{fileUploadBean.listener}" maxFilesQuantity="#{fileUploadBean.uploadsAvailable}" id="upload" immediateUpload="#{fileUploadBean.autoUpload}" acceptedTypes="jpg, gif, png, bmp" allowFlash="#{fileUploadBean.useFlash}"> <a4j:support event="onuploadcomplete" reRender="info" /> </rich:fileUpload>
FileUploadBean - this listener is never calledpublic void listener(UploadEvent event) throws IOException { System.out.println("LISTENER CALLED"); UploadItem item = event.getUploadItem(); File file = new File(); file.setLength(item.getData().length); file.setName(item.getFileName()); file.setData(item.getData()); files.add(file); uploadsAvailable--; }
The same application works as normal web application.
Any hints are very appreciated.
regards
Stefan -
4. Re: Can't get rich:fileUpload to work (using 2.0.0.A)
stefan_tausendpfund Dec 3, 2009 5:44 AM (in response to mlavannis)Hello wesley,
the getActionUrl is included now in 3.3.3-SNAPSHOT. So I tried it out. The Method is called on rendering but the upload event is still not fired. Is there something missing in my app or bridge?
thanks
Stefan -
5. Re: Can't get rich:fileUpload to work (using 2.0.0.A)
alexsmirnov Dec 3, 2009 3:34 PM (in response to mlavannis)Yes, that method has been introduced in the RichFaces 3.3.3, but it still does not used by the portletbridge.
The idea was to create portal-related FileUploadRenderer that provides direct link to Faces Servlet / richfaces filter in that method. To do that, modified method should call ViewHavdler#createActionUrl and then ExternalContext#encodeActionUrl methods with the parameter javax.portlet.faces.DirectLink and its value is true encoded into URL.
It would be wonderful if you can prototype such renderer and provide it as contribution to our project. -
6. Re: Can't get rich:fileUpload to work (using 2.0.0.A)
stefan_tausendpfund Dec 8, 2009 5:23 AM (in response to mlavannis)Hello Alex,
we use the portletbridge 2.0.0-SNAPSHOT. The getActionUrl will get there the PortletAjaxContext. So an Url for serveResource is generated there:RichFacesEchoPortletWindow?action=f&cacheability=PAGE&_jsfBridgeViewId=%2Fpages%2FfileUpload.xhtml&id=%2Ffaces%2Fpages%2FfileUpload.xhtml
This differs to older bridges. There a direct link to the FacesServlet is generated:<WebContext>/faces/pages/fileUpload.xhtml?javax.portlet.faces.DirectLink=true
Using the SNAPSHOT bridge the serveResource is called and the facesContext is executed. The parameter _richfaces_upload_file_indicator=true is set in request, but the FileUploadRendererBase#doDecode is not called (and so the storeData and the UploadEvent is not fired).
Do we really need to make a direct call to the FacesServlet or is there a way to get the serveResource running?
regards
Stefan -
7. Re: Can't get rich:fileUpload to work (using 2.0.0.A)
alexsmirnov Dec 10, 2009 7:41 PM (in response to mlavannis)ResourceRequest cannot process multipart requests, at least in the standard-compatible way ( jsr says nothing about that ), so servlet request is only legal way to upload files.
-
8. Re: Can't get rich:fileUpload to work (using 2.0.0.A)
stefan_tausendpfund Dec 15, 2009 10:40 AM (in response to alexsmirnov)Hello Alex,
today I had a look on the direct FacesServlet call. I changed the URL to <context>/pages/fileUpload.xhtml adding the DirectLink attribute. First of all the call failed as the view could not be restored in RestorePhase. So I switched to client side state saving. Now the client Id's differ because of the portlet namespace prefix and so invokeRoot is not called in AjaxViewRoot. Do you have additional hints here?
regards
Stefan
-
9. Re: Can't get rich:fileUpload to work (using 2.0.0.A)
stefan_tausendpfund Dec 18, 2009 3:39 AM (in response to stefan_tausendpfund)Hello Alexander,
just a short update: I changed the extend from MultipartRequest from HttpServletWrapper to MultipartRequestBase and added there all necessary methods. Also I added a constructor for the ResourceRequest.
For testing purposes I check in the portletbridge for multipart request in the RichfacesStrategy. If multipart is detected the MultipartRequest is added with ResourceRequest as request attribute. This works fine, the file is uploaded and handled by the MultipartRequest object. I need some additional debugging as there is a missing attribute in the doDecode.
regards
Stefan
-
10. Re: Can't get rich:fileUpload to work (using 2.0.0.A)
wesleyhales Dec 18, 2009 8:55 AM (in response to stefan_tausendpfund)Hi Stefan - Sounds like you have made some great progress. Thanks very much for your time on this!
Can you go ahead and attach a patch to this jira issue https://jira.jboss.org/jira/browse/PBR-134
I will also take a look and see if this can be added to the next 2.0 release, which I will have tagged this weekend
-
11. Re: Can't get rich:fileUpload to work (using 2.0.0.A)
stefan_tausendpfund Dec 19, 2009 8:15 AM (in response to wesleyhales)Hello Wesley,
unfortunately my jira user has not enough permission to change or add anything. You can download the diff from here:hxxp://80.190.140.117/patch.zip
Actually the two paramteres javax.portletbridge.STATE_ID and javax.faces.ViewState are not evaluated in multipart request. So the execution of facecontext does not restore the view properly and therefore the upload event is not fired.
regards
Stefan
-
12. Re: Can't get rich:fileUpload to work (using 2.0.0.A)
stefan_tausendpfund Dec 19, 2009 12:10 PM (in response to stefan_tausendpfund)Hello Wesley,
the uploaded patch works now. I needed to wrap the getRequestParameter methods in ResourceRequestExternalContextImpl to get the additional parameters from Multipartrequest.
regards
Stefan
-
13. Re: Can't get rich:fileUpload to work (using 2.0.0.A)
wesleyhales Dec 20, 2009 3:09 PM (in response to stefan_tausendpfund)Thanks again Stefan, I added the zip to the jira mentioned above. -
14. Re: Can't get rich:fileUpload to work (using 2.0.0.A)
stefan_tausendpfund Jan 8, 2010 4:36 AM (in response to wesleyhales)Hello Wesley,
first of all a Happy New Year and thanks a lot for integrating the patch in portletbridge.
Unfortunately the bridge is not uploaded to the snapshot repository in jboss.
Also I have some issues getting the upload running with IE-7/8 and allowFlash set to false. The component shows an transfer error although the upload works well. I had some look in JS and found that in FileUpload.js in method onload the IE tries to find the javax.faces.ViewState input element in response. The a4j:log shows that this is included in the response xml. But the findViewState fails to detect this attribut in response xml and prints out the transfer error.
On firefox the same setting works well. Setting allowFlash to true als works fine in IE too.
reagards
Stefan