掲示板

Upload File in jsf 2.0(mojara)

12年前 に PortletFaces Community Member によって更新されました。

Upload File in jsf 2.0(mojara)

Regular Member 投稿: 199 参加年月日: 12/04/03 最新の投稿
hi
i tried to do file upload in liferay through primefaces 3.0

JSF::
====
<h:form enctype="multipart/form-data">

<p:messages showDetail="true"/>

<p:fileUpload value="#{fileUploadController.file}" mode="simple"/>

<p:commandButton value="Submit" ajax="false"
actionListener="#{fileUploadController.upload}"/>
</h:form>


Class
=====

@ManagedBean
@RequestScoped
public class FileUploadController {

private UploadedFile file;

public UploadedFile getFile() {
return file;
}

public void setFile(UploadedFile file) {
this.file = file;
}

public void upload() {
try {

System.out.println("SIZE::" + file.getSize());
System.out.println("FileName"+file.getFileName());
FacesMessage msg = new FacesMessage("Succesful", file.getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, msg);
} catch (Exception e) {
e.printStackTrace();
}

}
}


But the output is nullpointrexception!..
how can i rectify this?..


thanks!..
thumbnail
12年前 に Johann Kneringer によって更新されました。

RE: Upload File in jsf 2.0(mojara)

Junior Member 投稿: 42 参加年月日: 11/11/10 最新の投稿
it is important, that you make it exactly like in the example...


so use 2 alloyfaces layouts, put in every layout a form with the same id!
thumbnail
12年前 に Neil Griffin によって更新されました。

RE: Upload File in jsf 2.0(mojara)

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
There is a new primefaces3-portlet demo available here:
http://www.liferay.com/community/liferay-projects/liferay-faces/demos#primefaces3-portlet

Currently it uses bridge:inputFile to do a full postback type of upload. It doesn't use p:fileUpload yet, but perhaps sometime in the near future after we get the following issue addressed in PrimeFaces:
http://code.google.com/p/primefaces/issues/detail?id=2905
thumbnail
11年前 に Neil Griffin によって更新されました。

RE: Upload File in jsf 2.0(mojara)

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
The p:fileUpload component is now working, but you'll need to upgrade to Liferay Faces Bridge 3.0.0-BETA2 (Liferay 6.0.x) or 3.1.0-BETA2 (Liferay 6.1.x)