Search in sources :

Example 1 with InputFile

use of com.liferay.faces.bridge.component.inputfile.InputFile in project liferay-faces-bridge-impl by liferay.

the class InputFileDelegationResponseWriter method startElement.

@Override
public void startElement(String name, UIComponent uiComponent) throws IOException {
    super.startElement(name, uiComponent);
    if ("input".equals(name)) {
        InputFile inputFile = (InputFile) uiComponent;
        String multiple = inputFile.getMultiple();
        if ("multiple".equalsIgnoreCase(multiple)) {
            super.writeAttribute("multiple", multiple, "multiple");
        }
    }
}
Also used : InputFile(com.liferay.faces.bridge.component.inputfile.InputFile)

Example 2 with InputFile

use of com.liferay.faces.bridge.component.inputfile.InputFile 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)2 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