Foren

Ajax File upload problem on mobile device

Muhammad Azeem, geändert vor 8 Jahren.

Ajax File upload problem on mobile device

New Member Beiträge: 16 Beitrittsdatum: 14.01.15 Neueste Beiträge
Hi,
I need ajax based feature to upload files in a portlet, I tried with primefaces, it worked fine for desktop but not working on mobile device as advance mode is not supported. Simple mode is also not working as it does not call the listener method.
I have tried following solution as mentioned in the primefaces4 it is working without ajax on both desktop and mobile
My XHTML
<!--?xml version="1.0"?-->

<f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui" xmlns:bridge="http://liferay.com/faces/bridge">
	<h:head />
	<h:body>
		<h:form enctype="multipart/form-data">
			<bridge:inputfile fileuploadlistener="#{myTestBean.handleFileUpload}"></bridge:inputfile>
			<p:commandbutton value="Submit" ajax="false"></p:commandbutton>
		</h:form>
	</h:body>
</f:view>

Managed Bean
package com.test.download;

import javax.faces.bean.ManagedBean;

import com.liferay.faces.bridge.event.FileUploadEvent;


@ManagedBean(name = "myTestBean")
public class MyTestBean {
	
	public void handleFileUpload(FileUploadEvent event) throws Exception {
		
		System.out.println("File Name is: " + event.getUploadedFile().getName());
		
	}	
}

This is working fine but I have two further requirements
1- This does not work if I remove ajax="false" from command button i.e. handleFileUpload method not called with ajax version.
2- How can I apply primefaces styles on input tag generated by <bridge:inputFile
thumbnail
Neil Griffin, geändert vor 8 Jahren.

RE: Ajax File upload problem on mobile device

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Hi Muhammad,

Is your mobile device android? If so, what version?

Also, does your mobile device successfully work with the p:fileUpload demo from the PrimeFaces Showcase?

Kind Regards,

Neil
Muhammad Azeem, geändert vor 8 Jahren.

RE: Ajax File upload problem on mobile device

New Member Beiträge: 16 Beitrittsdatum: 14.01.15 Neueste Beiträge
Hi Neil,
Thanks for your time, I am using android device (Samsung Note 2), android version is 4.4.2.

simple upload example upload is disabled for online demo. I will give it a try locally. But I tested the File Upload Single example and it is working fine.

Update
I tried both examples locally, everything works fine on both mobile and desktop but without renderKitId="PRIMEFACES_MOBILE" but when I use mobile render kit, advance modes does not work also ajax is not working with any simple or advance mode. I believe problem is using mobile render kit but I have to use this to have correct GUI on mobile device. Now question is that ajax file upload is supported on mobile render kit or not?
thumbnail
Neil Griffin, geändert vor 8 Jahren.

RE: Ajax File upload problem on mobile device

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Hi Muhammad,

Thanks for the update. When you wrote:
Muhammad Azeem:
I tried both examples locally, everything works fine on both mobile and desktop but without renderKitId="PRIMEFACES_MOBILE" but when I use mobile render kit, advance modes does not work also ajax is not working with any simple or advance mode. I believe problem is using mobile render kit but I have to use this to have correct GUI on mobile device. Now question is that ajax file upload is supported on mobile render kit or not?

Did you mean that you tried the PrimeFaces Showcase locally as a plain webapp, or do you mean that you tried something like our primefaces4-portlet demo running within Liferay Portal?

To answer your question about the PRIMEFACES_MOBILE renderkit, we do not currently provide support for it in a portlet environment. However, I recommend that you try PrimeFaces 5.2 and see if you get better results.

Thank you,

Neil
Muhammad Azeem, geändert vor 8 Jahren.

RE: Ajax File upload problem on mobile device

New Member Beiträge: 16 Beitrittsdatum: 14.01.15 Neueste Beiträge
Hi Neil,
I am already using primefaces 5.2. I have tried with both standalone primefaces web application as well as with liferay portlet. In both cases ajax file upload does not work with "PRIMEFACES_MOBILE". I believe issue is more related to primefaces, I will post the question on primfaces forum.

Thanks for your time and support.