All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openxava.actions.LoadAttachedFileAction Maven / Gradle / Ivy

There is a newer version: 7.4.3
Show newest version
package org.openxava.actions;

import java.util.*;

import org.apache.commons.fileupload.*;
import org.openxava.util.*;
import org.openxava.web.editors.*;

/**
 * Logic of AttachedFileEditor.load action in default-controllers.xml. 

* * Instance {@link org.openxava.web.editors.AttachedFile} object and stores it * in a file container.

* * @author Jeromy Altuna * @author Javier Paniza */ public class LoadAttachedFileAction extends AttachedFileBaseAction implements IProcessLoadedFileAction { @SuppressWarnings("rawtypes") private List fileItems; public void execute() throws Exception { Iterator it = getFileItems().iterator(); while (it.hasNext()) { FileItem fi = (FileItem) it.next(); if (!Is.emptyString(fi.getName())) { AttachedFile file = new AttachedFile(); file.setName(fi.getName()); file.setData(fi.get()); FilePersistorFactory.getInstance().save(file); getView().setValue(getProperty(), file.getId()); trackModification(file, "uploaded_to_file_property"); break; } } } @SuppressWarnings("rawtypes") public List getFileItems() { return fileItems; } @SuppressWarnings("rawtypes") public void setFileItems(List fileItems) { this.fileItems = fileItems; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy