Search in sources :

Example 1 with HtmlInputFile

use of javax.faces.component.html.HtmlInputFile in project liferay-faces-bridge-impl by liferay.

the class HtmlInputFileRenderer method decode.

@Override
public void decode(FacesContext facesContext, UIComponent uiComponent) {
    HtmlInputFile htmlInputFile = (HtmlInputFile) uiComponent;
    Map<String, List<UploadedFile>> uploadedFileMap = InputFileRenderer.getUploadedFileMap(facesContext);
    if (!uploadedFileMap.isEmpty()) {
        String clientId = uiComponent.getClientId(facesContext);
        if (uploadedFileMap.containsKey(clientId)) {
            List<UploadedFile> uploadedFiles = uploadedFileMap.get(clientId);
            if ((uploadedFiles != null) && (uploadedFiles.size() > 0)) {
                Part part = new PartFileUploadAdapterImpl(uploadedFiles.get(0), clientId);
                htmlInputFile.setTransient(true);
                htmlInputFile.setSubmittedValue(part);
            } else {
                htmlInputFile.setSubmittedValue(new PartEmptyImpl());
            }
        }
    }
    RendererUtil.decodeClientBehaviors(facesContext, uiComponent);
}
Also used : UploadedFile(com.liferay.faces.bridge.model.UploadedFile) HtmlInputFile(javax.faces.component.html.HtmlInputFile) Part(javax.servlet.http.Part) PartFileUploadAdapterImpl(com.liferay.faces.bridge.renderkit.bridge.internal.PartFileUploadAdapterImpl) List(java.util.List)

Aggregations

UploadedFile (com.liferay.faces.bridge.model.UploadedFile)1 PartFileUploadAdapterImpl (com.liferay.faces.bridge.renderkit.bridge.internal.PartFileUploadAdapterImpl)1 List (java.util.List)1 HtmlInputFile (javax.faces.component.html.HtmlInputFile)1 Part (javax.servlet.http.Part)1