File Upload

If files are uploaded as attachments of an entity, see Large Object and Media.

In general, to enable a file upload when creating an entity, add a property whose type is UploadedFile or a list of UploadedFile(s). For example,

public class MyType extends PersistenceEntityBase {
	private List<UploadedFile> photos; 

	public List<UploadedFile> getPhotos() {
		return photos;

	public void setPhotos(List<UploadedFile> photos) { = photos;
Annotate the file upload property as following in its EntityBackingBean:

public class MyTypeBean extends EntityBackingBean<MyType> {
	public boolean hasPropertyAnnotations() {
		return true; 
The uploaded files can be processed in action handler clickMenuNode(), validate(), preCreate() or postCreate() of its EntityBackingBean. For example, stream them into database CLOB or BLOB columns, or parse them to create other entities.

Open Upload Form

Another way to upload files is to open a separate upload form with a UploadListener. The listener will be called after files are uploaded. For example,

	UploadListener listener = new UploadListener() {

		public void filesUploaded(List<UploadedFile> uploadedFiles) throws IOException, SystemException {
			// do something

	FileUploadBean.showUploadForm(title, listener, containerRenderRegions);
The parameter containerRenderRegions specifies where to show the upload form. For example, show it in a region of a dialog or current containerBean.

Ajax and Progress

By default, files will be uploaded by ajax if HTML5 is supported by browser. Otherwise it will fall back to non-ajax POST.

In case of ajax upload, uploading progress will be shown including loaded, total, speed and time left if HTML5 progress is supported by browser.

Drag and Drop

Files can be selected, or dragged from File explorer and dropped into the marked droppable area. A list of files to be uploaded are listed with thumbnails for images.

Count, Size and Types

By default, the number of files, the size of each file and file types are umlimited.

To limit file upload size globally, user can set the upload maximum file size in system Parameters.(System -> Setup -> Parameters).

To limit file upload size, count and file types programmatically, set them in EntityFileUploadProperty instance. For example,

	EntityFileUploadProperty property = (EntityFileUploadProperty)getEntityProperty("attachments");
	property.setSizeLimit(50*1024);  // 50K