001/*
002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Florent Guillaume
016 */
017package org.nuxeo.ecm.platform.ui.web.component.file;
018
019import java.io.IOException;
020
021import javax.faces.component.UIInput;
022import javax.faces.context.FacesContext;
023
024/**
025 * Interface for a Blob Uploader, a JSF helper that knows how to encode and validate a component to provide blob input
026 * in the JSF UI.
027 *
028 * @since 7.2
029 */
030public interface JSFBlobUploader {
031
032    /**
033     * Gets the choice key associated to this uploader. This MUST start with "upload" for the display logic to work
034     * correctly.
035     */
036    String getChoice();
037
038    /**
039     * Constructs the needed subcomponent.
040     */
041    void hookSubComponent(UIInput parent);
042
043    /**
044     * Generates the HTML for an upload choice.
045     */
046    void encodeBeginUpload(UIInput parent, FacesContext context, String onClick) throws IOException;
047
048    /**
049     * Transforms input into a blob.
050     *
051     * @param submitted the value into which the input is stored
052     */
053    void validateUpload(UIInput parent, FacesContext context, InputFileInfo submitted);
054
055    /**
056     * Checks if the uploader is enabled. Only enabled uploaders are added to the UI.
057     *
058     * @since 7.4
059     */
060    boolean isEnabled();
061
062}