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());
}
}
Aggregations