Search in sources :

Example 1 with FileUploadEvent

use of com.liferay.faces.alloy.component.inputfile.FileUploadEvent in project liferay-faces-alloy by liferay.

the class InputFileRenderer method decode.

@Override
public void decode(FacesContext facesContext, UIComponent uiComponent) {
    InputFile inputFile = (InputFile) uiComponent;
    Map<String, List<UploadedFile>> uploadedFileMap = getUploadedFileMap(facesContext, inputFile.getLocation());
    if (uploadedFileMap != null) {
        String clientId = uiComponent.getClientId(facesContext);
        List<UploadedFile> uploadedFiles = uploadedFileMap.get(clientId);
        if ((uploadedFiles != null) && (uploadedFiles.size() > 0)) {
            inputFile.setSubmittedValue(uploadedFiles);
            // ActionListener.
            for (UploadedFile uploadedFile : uploadedFiles) {
                FileUploadEvent fileUploadEvent = new FileUploadEvent(uiComponent, uploadedFile);
                uiComponent.queueEvent(fileUploadEvent);
            }
        } else // FACES-3136: Ensure that the required attribute is enforced.
        {
            inputFile.setSubmittedValue(Collections.emptyList());
        }
    } else // FACES-3136: Ensure that the required attribute is enforced.
    {
        inputFile.setSubmittedValue(Collections.emptyList());
    }
}
Also used : UploadedFile(com.liferay.faces.util.model.UploadedFile) FileUploadEvent(com.liferay.faces.alloy.component.inputfile.FileUploadEvent) List(java.util.List) InputFile(com.liferay.faces.alloy.component.inputfile.InputFile)

Aggregations

FileUploadEvent (com.liferay.faces.alloy.component.inputfile.FileUploadEvent)1 InputFile (com.liferay.faces.alloy.component.inputfile.InputFile)1 UploadedFile (com.liferay.faces.util.model.UploadedFile)1 List (java.util.List)1