Class FileUploadController

java.lang.Object
org.imixs.workflow.faces.fileupload.FileUploadController
All Implemented Interfaces:
Serializable

@Named @ConversationScoped public class FileUploadController extends Object implements Serializable
The FileUploadController is a conversation scoped JSF 4.0 component used to transfer the parts to the associated workitem. The controller supports two modes:

SingleMode:

In this mode one or multiple files can be transferred in a one request. This is mainly covered by JavaScript code and works in a simple straight forward way.

AjaxMode:

In the ajax mode one or multiple files can be transferred sequentiell in separate ajax request. This mode is more user friendly.

 
        <i:imixsFileUpload id="file_upload_id" 
       showattachments="true"
       workitem="#{workflowController.workitem}"
       labelButton="#{message.documents_upload}" 
       labelHelp="#{message.documents_upload_help}"/>
    
Author:
rsoika
See Also:
  • Field Details

  • Constructor Details

    • FileUploadController

      public FileUploadController()
  • Method Details

    • getFiles

      public List<jakarta.servlet.http.Part> getFiles()
    • setFiles

      public void setFiles(List<jakarta.servlet.http.Part> files)
    • getWorkitem

      public ItemCollection getWorkitem()
    • setWorkitem

      public void setWorkitem(ItemCollection workitem)
    • onWorkflowEvent

      public void onWorkflowEvent(@Observes @Priority(1000) WorkflowEvent workflowEvent) throws PluginException
      WorkflowEvent listener to add uploaded file parts into the current workitem. If no workitem was specified the component takes the workitem of the WorkflowController. The observer runs before normal application observers (Interceptor.Priority.LIBRARY_BEFORE)
      Parameters:
      workflowEvent -
      Throws:
      AccessDeniedException
      PluginException
    • onDocumentEvent

      public void onDocumentEvent(@Observes @Priority(1000) DocumentEvent documentEvent) throws PluginException
      In case no WorkflowController was used we observer also the before Save event
      Parameters:
      documentEvent -
      Throws:
      PluginException
    • attacheFiles

      public void attacheFiles(ItemCollection workitem) throws PluginException
      Attaches the uploaded file objects to the current workitem.
      Throws:
      PluginException
    • addAttachedFile

      public void addAttachedFile(FileData fileData)
      The method adds a FileData object to the workitem For example this method is used by the Imixs WopiController
      Parameters:
      fileData -
    • removeAttachedFile

      public void removeAttachedFile(String aFilename)
      Removes a attached file object from the tmp list of uploaded files.
      Parameters:
      sFilename - - filename to be removed
    • getUserInfo

      public String getUserInfo(String aFilename)
      Returns the user info (creator / modified) by filename
      Returns:
    • getFileSize

      public String getFileSize(String aFilename)
      get the file size for a given filename in human readable format

      In case the Imixs-Archive API is connected, the file size is stored in the attriubte 'size'

      Parameters:
      sFilename - - filename to be removed
      Returns:
      - filsize in human readable string
    • round

      public static double round(double value)
      helper method to round for 2 digits.
      Parameters:
      value -
      places -
      Returns:
    • getCID

      public String getCID()
      Returns the current conversation id. This id is passed to the AjaxFileUploadServelt URIs so make sure that the correct FileUploadController is injected.
      Returns:
    • getFileUploads

      public List<FileData> getFileUploads()
      returns the list of currently new attached files. This list is not equal the $file item! This method is called by the AjaxFileUpload Servlet.
      Returns:
    • getFileUpload

      public FileData getFileUpload(String fileName)
      returns the single fileData object form the upload list by name This method is called by the AjaxFileUpload Servlet.
      Returns:
    • addFileUpload

      public void addFileUpload(FileData fileData)
      Adds a FileData object to the uploaded File list
      Parameters:
      document -
      aFilename -
    • removeFileUpload

      public void removeFileUpload(String aFilename)
      Removes a FileData object from the uploaded File list
      Parameters:
      document -
      aFilename -