Foros de discusión

Liferay 6.2 + Primefaces 6 + File Download

Deniz Burucu, modificado hace 7 años.

Liferay 6.2 + Primefaces 6 + File Download

New Member Mensajes: 10 Fecha de incorporación: 10/06/15 Mensajes recientes
I have a button to download in view:

	<p:commandlink value="Download" ajax="false" styleclass="btn btn-primary">
		<p:filedownload value="#{DownloadController.downloadFile()}" />
	</p:commandlink>


In DownloadController:

@ViewScoped
@ManagedBean(name = "DownloadController")
public class DownloadController {
	...
	public StreamedContent downloadFile() throws Exception {
		//check file and restrictions
		bAllowed = false;
		if (!bAllowed) {
			return null;
		}
		//prepare file to download
		...
		//send file to user
	}
	...


How can I break a download action?
I am checking the restrictions for the user and file etc. If I return null, Liferay reload page and its only shown partially and without css.
If I return the File, everything is ok.
How can I write it correctly?
thumbnail
Neil Griffin, modificado hace 7 años.

RE: Liferay 6.2 + Primefaces 6 + File Download

Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
I recommend that you try the accepted answer to the StackOverflow question titled Primefaces filedownload error handling.