掲示板

Liferay 6.2 + Primefaces 6 + File Download

7年前 に Deniz Burucu によって更新されました。

Liferay 6.2 + Primefaces 6 + File Download

New Member 投稿: 10 参加年月日: 15/06/10 最新の投稿
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
7年前 に Neil Griffin によって更新されました。

RE: Liferay 6.2 + Primefaces 6 + File Download

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
I recommend that you try the accepted answer to the StackOverflow question titled Primefaces filedownload error handling.