Search in sources :

Example 1 with FileUploadEvent

use of com.liferay.faces.bridge.event.FileUploadEvent in project liferay-faces-bridge-impl 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);
    if (!uploadedFileMap.isEmpty()) {
        String clientId = uiComponent.getClientId(facesContext);
        List<UploadedFile> uploadedFiles = uploadedFileMap.get(clientId);
        if ((uploadedFiles != null) && (uploadedFiles.size() > 0)) {
            List<com.liferay.faces.bridge.model.UploadedFile> bridgeUploadedFiles = new ArrayList<com.liferay.faces.bridge.model.UploadedFile>(uploadedFiles.size());
            for (UploadedFile uploadedFile : uploadedFiles) {
                bridgeUploadedFiles.add(uploadedFile);
            }
            inputFile.setSubmittedValue(bridgeUploadedFiles);
            // 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 : ArrayList(java.util.ArrayList) InputFile(com.liferay.faces.bridge.component.inputfile.InputFile) UploadedFile(com.liferay.faces.bridge.model.UploadedFile) FileUploadEvent(com.liferay.faces.bridge.event.FileUploadEvent) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

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