Package org.openfaces.component.input.fileattachments

Examples of org.openfaces.component.input.fileattachments.FileAttachments


        final DownloadAttachmentAction downloadAttachmentAction = (DownloadAttachmentAction) component;
        invokeFileDownloadListener(context, downloadAttachmentAction);
    }

    private void invokeFileDownloadListener(FacesContext context, DownloadAttachmentAction downloadAttachmentAction) {
        final FileAttachments fileAttachmentsComponent = downloadAttachmentAction.getFileAttachmentsComponent();
        if (fileAttachmentsComponent != null) {
            String key = fileAttachmentsComponent.getClientId(context) + DOWNLOAD_KEY;
            final ExternalContext externalContext = context.getExternalContext();
            final Map<String, String> requestParameterMap = externalContext.getRequestParameterMap();
            if (requestParameterMap.containsKey(key) && requestParameterMap.get(key).equals("true")) {
                MethodExpression fileDownloadListener = fileAttachmentsComponent.getFileDownloadListener();
                if (fileDownloadListener != null) {
                    fileDownloadListener.invoke(
                            context.getELContext(), new Object[]{
                            new FileDownloadEvent(fileAttachmentsComponent, downloadAttachmentAction.getFileAttachment())});
                }
View Full Code Here


    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        AbstractFileAttachmentAction abstractFileAttachmentAction = (AbstractFileAttachmentAction) component;
        Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
        final FileAttachment fileAttachment = (FileAttachment) requestMap.get(FileAttachmentsRenderer.REQ_FILE_ATTACHMENT_KEY);
        abstractFileAttachmentAction.setFileAttachment(fileAttachment);
        final FileAttachments fileAttachmentsComponent = (FileAttachments) requestMap.get(FileAttachmentsRenderer.REQ_FILE_ATTACHMENTS_COMP_KEY);
        abstractFileAttachmentAction.setFileAttachmentsComponent(fileAttachmentsComponent);
        encodeComponent(context, abstractFileAttachmentAction);
        encodeScriptAndStyles(context, abstractFileAttachmentAction);

    }
View Full Code Here

            invokerId = component.getParent().getClientId(context);
        else
            invokerId = null;

        ScriptBuilder sb = new ScriptBuilder();
        final FileAttachments attachmentsComponent = component.getFileAttachmentsComponent();
        sb.initScript(context, component, getScriptInitFunction(),
                invokerId,
                Rendering.getEventWithOnPrefix(context, component, getComponentName()),
                attachmentsComponent.getImmutableClientId(),
                component.getFileAttachment().getId()
        );

        Rendering.renderInitScript(context, sb, Resources.internalURL(context, AbstractAttachmentActionRenderer.JS_SCRIPT_URL));
    }
View Full Code Here

    @Override
    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        AjaxUtil.prepareComponentForAjax(context, component);

        FileAttachments fileAttachments = (FileAttachments) component;
        renderStartTagOfComponent(context, fileAttachments);
    }
View Full Code Here

    }

    @Override
    public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
        ResponseWriter writer = context.getResponseWriter();
        FileAttachments fileAttachments = (FileAttachments) component;
        final String clientId = fileAttachments.getClientId(context);
        ChildData childData = getChildData(fileAttachments);
        writer.startElement("table", fileAttachments);
        writer.writeAttribute("id", clientId + ATTACHMENTS_LIST_ID, null);

        TableStructure tableStructure = childData.getTableStructure();
        TableHeader tableHeader = tableStructure.getHeader();
        if (tableHeader.isContentSpecified()) {
            tableHeader.render(context, null);
        }
        writer.startElement("tbody", fileAttachments);
        renderRows(context, fileAttachments, childData, fileAttachments.getValue());
        writer.endElement("tbody");

        TableFooter tableFooter = tableStructure.getFooter();
        if (tableFooter.isContentSpecified()) {
            tableFooter.render(context, null);
View Full Code Here

        writer.endElement("table");
    }

    @Override
    public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
        FileAttachments fileAttachments = (FileAttachments) component;
        final ResponseWriter writer = context.getResponseWriter();
        writeAttachButton(context, fileAttachments, writer);
        encodeScriptAndStyles(context, fileAttachments);
        writer.endElement("div");
    }
View Full Code Here

    @Override
    public void decode(FacesContext context, UIComponent component) {
    }

    public JSONObject encodeAjaxPortion(FacesContext context, UIComponent component, String portionName, JSONObject jsonParam) throws IOException, JSONException {
        FileAttachments fileAttachments = (FileAttachments) component;
        JSONObject jsonObj = new JSONObject();
        if (jsonParam.has(A_P_CALL_REMOVE_LISTENER)) {
            if (jsonParam.has(A_P_ID_OF_ATTACHMENT)) {
                String id = (String) jsonParam.get(A_P_ID_OF_ATTACHMENT);
                MethodExpression fileRemovedListener = fileAttachments.getFileRemovedListener();

                if (fileRemovedListener != null) {
                    final FileAttachment attachment = getAttachmentFromListWithId(fileAttachments.getValue(), id);
                    fileRemovedListener.invoke(
                            context.getELContext(), new Object[]{
                            new FileRemovedEvent(fileAttachments, attachment)});
                }
                Rendering.addJsonParam(jsonObj, "isCalled", true);
View Full Code Here

TOP

Related Classes of org.openfaces.component.input.fileattachments.FileAttachments

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.