Search in sources :

Example 1 with FileUploadField

use of com.extjs.gxt.ui.client.widget.form.FileUploadField in project kura by eclipse.

the class FileUploadDialog method onRender.

@Override
protected void onRender(Element parent, int pos) {
    super.onRender(parent, pos);
    setLayout(new FormLayout());
    setBodyBorder(false);
    setModal(true);
    setButtons("");
    setScrollMode(Scroll.AUTO);
    setHideOnButtonClick(false);
    setSize(400, 125);
    m_formPanel = new FormPanel();
    m_formPanel.setFrame(false);
    m_formPanel.setHeaderVisible(false);
    m_formPanel.setBodyBorder(false);
    m_formPanel.setAction(m_url);
    m_formPanel.setEncoding(Encoding.MULTIPART);
    m_formPanel.setMethod(Method.POST);
    m_formPanel.setButtonAlign(HorizontalAlignment.CENTER);
    m_formPanel.setLabelWidth(50);
    m_formPanel.addListener(Events.Submit, new Listener<FormEvent>() {

        public void handleEvent(FormEvent be) {
            String htmlResponse = be.getResultHtml();
            if (htmlResponse == null || htmlResponse.isEmpty()) {
                MessageBox.info(MSGS.information(), MSGS.fileUploadSuccess(), null);
            } else {
                String errMsg = htmlResponse;
                int startIdx = htmlResponse.indexOf("<pre>");
                int endIndex = htmlResponse.indexOf("</pre>");
                if (startIdx != -1 && endIndex != -1) {
                    errMsg = htmlResponse.substring(startIdx + 5, endIndex);
                }
                MessageBox.alert(MSGS.error(), MSGS.fileUploadFailure() + ": " + errMsg, null);
            }
            hide();
        }
    });
    m_fileUploadField = new FileUploadField();
    m_fileUploadField.setAllowBlank(false);
    m_fileUploadField.setName("uploadedFile");
    m_fileUploadField.setFieldLabel(MSGS.fileLabel());
    m_formPanel.add(m_fileUploadField);
    if (m_hiddenFields != null) {
        for (HiddenField<?> hf : m_hiddenFields) {
            m_formPanel.add(hf);
        }
    }
    // 
    // xsrfToken Hidden field
    // 
    gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

        @Override
        public void onFailure(Throwable ex) {
            FailureHandler.handle(ex);
        }

        @Override
        public void onSuccess(GwtXSRFToken token) {
            xsrfTokenField.setValue(token.getToken());
        }
    });
    xsrfTokenField = new HiddenField<String>();
    xsrfTokenField.setId("xsrfToken");
    xsrfTokenField.setName("xsrfToken");
    xsrfTokenField.setValue("");
    m_formPanel.add(xsrfTokenField);
    // 
    add(m_formPanel);
}
Also used : FormLayout(com.extjs.gxt.ui.client.widget.layout.FormLayout) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) FormEvent(com.extjs.gxt.ui.client.event.FormEvent) GwtXSRFToken(org.eclipse.kura.web.shared.model.GwtXSRFToken) FileUploadField(com.extjs.gxt.ui.client.widget.form.FileUploadField)

Example 2 with FileUploadField

use of com.extjs.gxt.ui.client.widget.form.FileUploadField in project kura by eclipse.

the class CommandTab method onRender.

protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FitLayout());
    setId("device-command");
    FormData formData = new FormData("100%");
    // 
    // Command Form
    // 
    m_formPanel = new FormPanel();
    m_formPanel.setFrame(true);
    m_formPanel.setHeaderVisible(false);
    m_formPanel.setBorders(false);
    m_formPanel.setBodyBorder(false);
    m_formPanel.setAction(SERVLET_URL);
    m_formPanel.setEncoding(Encoding.MULTIPART);
    m_formPanel.setMethod(Method.POST);
    m_formPanel.setButtonAlign(HorizontalAlignment.RIGHT);
    m_buttonBar = m_formPanel.getButtonBar();
    initButtonBar();
    m_formPanel.addListener(Events.Submit, new Listener<FormEvent>() {

        public void handleEvent(FormEvent be) {
            String htmlResult = be.getResultHtml();
            if (htmlResult.startsWith("HTTP ERROR")) {
                MessageBox.info(MSGS.information(), MSGS.fileUploadFailure() + "\n" + htmlResult, null);
                m_commandInput.unmask();
            } else {
                gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

                    @Override
                    public void onFailure(Throwable ex) {
                        FailureHandler.handle(ex);
                    }

                    @Override
                    public void onSuccess(GwtXSRFToken token) {
                        gwtDeviceService.executeCommand(token, m_commandField.getValue(), m_passwordField.getValue(), new AsyncCallback<String>() {

                            public void onFailure(Throwable caught) {
                                if (caught.getLocalizedMessage().equals(GwtKuraErrorCode.SERVICE_NOT_ENABLED.toString())) {
                                    Info.display(MSGS.error(), MSGS.commandServiceNotEnabled());
                                } else if (caught.getLocalizedMessage().equals(GwtKuraErrorCode.ILLEGAL_ARGUMENT.toString())) {
                                    Info.display(MSGS.error(), MSGS.commandPasswordNotCorrect());
                                } else {
                                    Info.display(MSGS.error(), caught.getLocalizedMessage());
                                }
                                // FailureHandler.handle(caught);
                                m_commandInput.unmask();
                                gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

                                    @Override
                                    public void onFailure(Throwable ex) {
                                        FailureHandler.handle(ex);
                                    }

                                    @Override
                                    public void onSuccess(GwtXSRFToken token) {
                                        xsrfTokenField.setValue(token.getToken());
                                    }
                                });
                            }

                            public void onSuccess(String result) {
                                m_result.clear();
                                m_result.setValue(result);
                                m_commandInput.unmask();
                                gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

                                    @Override
                                    public void onFailure(Throwable ex) {
                                        FailureHandler.handle(ex);
                                    }

                                    @Override
                                    public void onSuccess(GwtXSRFToken token) {
                                        xsrfTokenField.setValue(token.getToken());
                                    }
                                });
                            }
                        });
                    }
                });
            }
        }
    });
    // 
    // Command Output
    // 
    m_commandOutput = new LayoutContainer();
    m_commandOutput.setBorders(false);
    m_commandOutput.setWidth("99.5%");
    m_commandOutput.setLayout(new FitLayout());
    m_result = new TextArea();
    m_result.setBorders(false);
    m_result.setReadOnly(true);
    m_result.setEmptyText(MSGS.deviceCommandNoOutput());
    m_commandOutput.add(m_result);
    // 
    // Input and Upload
    // 
    m_commandField = new TextField<String>();
    m_commandField.setName("command");
    m_commandField.setAllowBlank(false);
    m_commandField.setFieldLabel(MSGS.deviceCommandExecute());
    m_formPanel.add(m_commandField, formData);
    m_passwordField = new TextField<String>();
    m_passwordField.setName("password");
    m_passwordField.setPassword(true);
    m_passwordField.setAllowBlank(true);
    m_passwordField.setFieldLabel(MSGS.deviceCommandPassword());
    m_formPanel.add(m_passwordField, formData);
    m_fileUploadField = new FileUploadField();
    m_fileUploadField.setAllowBlank(true);
    m_fileUploadField.setName("file");
    m_fileUploadField.setFieldLabel("File");
    m_formPanel.add(m_fileUploadField, formData);
    // 
    // xsrfToken Hidden field
    // 
    gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

        @Override
        public void onFailure(Throwable ex) {
            FailureHandler.handle(ex);
        }

        @Override
        public void onSuccess(GwtXSRFToken token) {
            xsrfTokenField.setValue(token.getToken());
        }
    });
    xsrfTokenField = new HiddenField<String>();
    xsrfTokenField.setId("xsrfToken");
    xsrfTokenField.setName("xsrfToken");
    xsrfTokenField.setValue("");
    m_formPanel.add(xsrfTokenField);
    // 
    m_commandInput = m_formPanel;
    // Main Panel
    ContentPanel deviceCommandPanel = new ContentPanel();
    deviceCommandPanel.setBorders(false);
    deviceCommandPanel.setBodyBorder(false);
    deviceCommandPanel.setHeaderVisible(false);
    deviceCommandPanel.setScrollMode(Scroll.AUTO);
    deviceCommandPanel.setLayout(new FitLayout());
    deviceCommandPanel.setTopComponent(m_commandInput);
    deviceCommandPanel.add(m_commandOutput);
    add(deviceCommandPanel);
}
Also used : FormData(com.extjs.gxt.ui.client.widget.layout.FormData) TextArea(com.extjs.gxt.ui.client.widget.form.TextArea) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GwtXSRFToken(org.eclipse.kura.web.shared.model.GwtXSRFToken) FileUploadField(com.extjs.gxt.ui.client.widget.form.FileUploadField) ContentPanel(com.extjs.gxt.ui.client.widget.ContentPanel) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) FormEvent(com.extjs.gxt.ui.client.event.FormEvent) LayoutContainer(com.extjs.gxt.ui.client.widget.LayoutContainer) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout)

Example 3 with FileUploadField

use of com.extjs.gxt.ui.client.widget.form.FileUploadField in project kura by eclipse.

the class PackageInstallDialog method onRender.

@Override
protected void onRender(Element parent, int pos) {
    super.onRender(parent, pos);
    setLayout(new FitLayout());
    setBodyBorder(false);
    setModal(true);
    setButtons("");
    setScrollMode(Scroll.AUTO);
    setHideOnButtonClick(false);
    setSize(400, 175);
    m_tabsPanel = new TabPanel();
    m_tabsPanel.setPlain(true);
    m_tabsPanel.setBorders(false);
    // 
    // File upload tab
    m_formPanelFile = new FormPanel();
    m_formPanelFile.setFrame(false);
    m_formPanelFile.setHeaderVisible(false);
    m_formPanelFile.setBodyBorder(false);
    m_formPanelFile.setAction(m_actionUrl + "/upload");
    m_formPanelFile.setEncoding(Encoding.MULTIPART);
    m_formPanelFile.setMethod(Method.POST);
    m_formPanelFile.setButtonAlign(HorizontalAlignment.CENTER);
    m_formPanelFile.setStyleAttribute("padding-right", "0px");
    m_formPanelFile.addListener(Events.Submit, new Listener<FormEvent>() {

        public void handleEvent(FormEvent be) {
            String htmlResponse = be.getResultHtml();
            if (htmlResponse == null || htmlResponse.isEmpty()) {
                MessageBox.info(MSGS.information(), MSGS.fileUploadSuccess(), null);
            } else {
                MessageBox.info(MSGS.information(), MSGS.fileUploadFailure(), null);
            }
            hide();
        }
    });
    FieldSet fileFieldSet = new FieldSet();
    fileFieldSet.setBorders(false);
    fileFieldSet.setStyleAttribute("padding", "0px");
    FormLayout fileFormLayout = new FormLayout();
    fileFormLayout.setLabelWidth(Constants.LABEL_WIDTH_FORM_SMALL);
    fileFieldSet.setLayout(fileFormLayout);
    m_fileUploadField = new FileUploadField();
    m_fileUploadField.setAllowBlank(false);
    m_fileUploadField.setName("uploadedFile");
    m_fileUploadField.setFieldLabel(MSGS.fileLabel());
    if (m_hiddenFields != null) {
        for (HiddenField<?> hf : m_hiddenFields) {
            fileFieldSet.add(hf);
        }
    }
    FormData fileFormData = new FormData("-20");
    fileFormData.setMargins(new Margins(0, 0, 0, 0));
    fileFieldSet.add(m_fileUploadField, fileFormData);
    m_formPanelFile.add(fileFieldSet, fileFormData);
    m_tabFile = new TabItem(MSGS.fileLabel());
    m_tabFile.setBorders(true);
    m_tabFile.setLayout(new FormLayout());
    m_tabFile.add(m_formPanelFile);
    m_tabsPanel.add(m_tabFile);
    // 
    // xsrfToken Hidden field
    // 
    gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

        @Override
        public void onFailure(Throwable ex) {
            FailureHandler.handle(ex);
        }

        @Override
        public void onSuccess(GwtXSRFToken token) {
            xsrfTokenFieldFile.setValue(token.getToken());
            xsrfTokenFieldUrl.setValue(token.getToken());
        }
    });
    xsrfTokenFieldFile = new HiddenField<String>();
    xsrfTokenFieldFile.setId("xsrfToken");
    xsrfTokenFieldFile.setName("xsrfToken");
    xsrfTokenFieldFile.setValue("");
    m_formPanelFile.add(xsrfTokenFieldFile);
    // 
    // 
    // Download URL tab
    m_formPanelUrl = new FormPanel();
    m_formPanelUrl.setFrame(false);
    m_formPanelUrl.setHeaderVisible(false);
    m_formPanelUrl.setBodyBorder(false);
    m_formPanelUrl.setAction(m_actionUrl + "/url");
    m_formPanelUrl.setMethod(Method.POST);
    m_formPanelUrl.setStyleAttribute("padding-right", "0px");
    m_formPanelUrl.addListener(Events.Submit, new Listener<FormEvent>() {

        public void handleEvent(FormEvent be) {
            String htmlResponse = be.getResultHtml();
            if (htmlResponse == null || htmlResponse.isEmpty()) {
                MessageBox.info(MSGS.information(), MSGS.fileDownloadSuccess(), null);
            } else {
                String errMsg = htmlResponse;
                int startIdx = htmlResponse.indexOf("<pre>");
                int endIndex = htmlResponse.indexOf("</pre>");
                if (startIdx != -1 && endIndex != -1) {
                    errMsg = htmlResponse.substring(startIdx + 5, endIndex);
                }
                MessageBox.alert(MSGS.error(), MSGS.fileDownloadFailure() + ": " + errMsg, null);
            }
            hide();
        }
    });
    FieldSet urlFieldSet = new FieldSet();
    urlFieldSet.setBorders(false);
    urlFieldSet.setStyleAttribute("padding", "0px");
    FormLayout urlFormLayout = new FormLayout();
    urlFormLayout.setLabelWidth(Constants.LABEL_WIDTH_FORM_SMALL);
    urlFieldSet.setLayout(urlFormLayout);
    m_textFieldUrl = new TextField<String>();
    m_textFieldUrl.setAllowBlank(false);
    m_textFieldUrl.setName("packageUrl");
    m_textFieldUrl.setFieldLabel(MSGS.urlLabel());
    FormData urlFormData = new FormData("-20");
    urlFormData.setMargins(new Margins(0, 0, 0, 0));
    urlFieldSet.add(m_textFieldUrl, urlFormData);
    if (m_hiddenFields != null) {
        for (HiddenField<?> hf : m_hiddenFields) {
            urlFieldSet.add(hf);
        }
    }
    m_formPanelUrl.add(urlFieldSet, urlFormData);
    // 
    // xsrfToken Hidden field
    // 
    xsrfTokenFieldUrl = new HiddenField<String>();
    xsrfTokenFieldUrl.setId("xsrfToken");
    xsrfTokenFieldUrl.setName("xsrfToken");
    xsrfTokenFieldUrl.setValue("");
    m_formPanelUrl.add(xsrfTokenFieldUrl);
    // 
    m_tabUrl = new TabItem(MSGS.urlLabel());
    m_tabUrl.setBorders(true);
    m_tabUrl.setLayout(new FormLayout());
    m_tabUrl.add(m_formPanelUrl);
    m_tabsPanel.add(m_tabUrl);
    add(m_tabsPanel);
}
Also used : TabPanel(com.extjs.gxt.ui.client.widget.TabPanel) FormLayout(com.extjs.gxt.ui.client.widget.layout.FormLayout) FormData(com.extjs.gxt.ui.client.widget.layout.FormData) GwtXSRFToken(org.eclipse.kura.web.shared.model.GwtXSRFToken) FileUploadField(com.extjs.gxt.ui.client.widget.form.FileUploadField) TabItem(com.extjs.gxt.ui.client.widget.TabItem) FieldSet(com.extjs.gxt.ui.client.widget.form.FieldSet) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) FormEvent(com.extjs.gxt.ui.client.event.FormEvent) Margins(com.extjs.gxt.ui.client.util.Margins) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout)

Example 4 with FileUploadField

use of com.extjs.gxt.ui.client.widget.form.FileUploadField in project kapua by eclipse.

the class DeviceTabCommand method initCommandInput.

private void initCommandInput() {
    FormData formData = new FormData("-20");
    FormLayout layout = new FormLayout();
    layout.setLabelWidth(Constants.LABEL_WIDTH_FORM);
    FieldSet fieldSet = new FieldSet();
    fieldSet.setBorders(false);
    fieldSet.setLayout(layout);
    fieldSet.setStyleAttribute("margin", "0px");
    fieldSet.setStyleAttribute("padding", "0px");
    m_formPanel = new FormPanel();
    m_formPanel.setFrame(true);
    m_formPanel.setHeaderVisible(false);
    m_formPanel.setBorders(false);
    m_formPanel.setBodyBorder(false);
    m_formPanel.setAction(SERVLET_URL);
    m_formPanel.setEncoding(Encoding.MULTIPART);
    m_formPanel.setMethod(Method.POST);
    m_formPanel.add(fieldSet);
    m_formPanel.addListener(Events.Render, new Listener<BaseEvent>() {

        public void handleEvent(BaseEvent be) {
            NodeList<com.google.gwt.dom.client.Element> nl = m_formPanel.getElement().getElementsByTagName("form");
            if (nl.getLength() > 0) {
                com.google.gwt.dom.client.Element elemForm = nl.getItem(0);
                elemForm.setAttribute("autocomplete", "off");
            }
        }
    });
    m_formPanel.setButtonAlign(HorizontalAlignment.RIGHT);
    m_buttonBar = m_formPanel.getButtonBar();
    initButtonBar();
    m_formPanel.addListener(Events.BeforeSubmit, new Listener<BaseEvent>() {

        @Override
        public void handleEvent(BaseEvent be) {
            if (!m_selectedDevice.isOnline()) {
                MessageBox.alert(MSGS.alerts(), MSGS.deviceOffline(), new Listener<MessageBoxEvent>() {

                    @Override
                    public void handleEvent(MessageBoxEvent be) {
                        m_commandInput.unmask();
                    }
                });
                be.setCancelled(true);
            }
        }
    });
    m_formPanel.addListener(Events.Submit, new Listener<FormEvent>() {

        @Override
        public void handleEvent(FormEvent be) {
            String htmlResult = be.getResultHtml();
            // 
            if (!htmlResult.startsWith("<pre")) {
                int errorMessageStartIndex = htmlResult.indexOf("<pre");
                errorMessageStartIndex = htmlResult.indexOf(">", errorMessageStartIndex) + 1;
                int errorMessageEndIndex = htmlResult.indexOf("</pre>");
                String errorMessage = htmlResult.substring(errorMessageStartIndex, errorMessageEndIndex);
                MessageBox.alert(MSGS.error(), MSGS.fileUploadFailure() + ":<br/>" + errorMessage, null);
                m_commandInput.unmask();
            } else {
                int outputMessageStartIndex = htmlResult.indexOf("<pre");
                outputMessageStartIndex = htmlResult.indexOf(">", outputMessageStartIndex) + 1;
                int outputMessageEndIndex = htmlResult.indexOf("</pre>");
                String output = htmlResult.substring(outputMessageStartIndex, outputMessageEndIndex);
                m_result.setValue(KapuaSafeHtmlUtils.htmlUnescape(output));
                m_commandInput.unmask();
            }
        }
    });
    m_accountField = new HiddenField<String>();
    m_accountField.setName("scopeIdString");
    fieldSet.add(m_accountField);
    m_deviceIdField = new HiddenField<String>();
    m_deviceIdField.setName("deviceIdString");
    fieldSet.add(m_deviceIdField);
    m_timeoutField = new HiddenField<Integer>();
    m_timeoutField.setName("timeout");
    fieldSet.add(m_timeoutField);
    // 
    // xsrfToken Hidden field
    // 
    xsrfTokenField = new HiddenField<String>();
    xsrfTokenField.setId("xsrfToken");
    xsrfTokenField.setName("xsrfToken");
    xsrfTokenField.setValue("");
    fieldSet.add(xsrfTokenField);
    m_commandField = new TextField<String>();
    m_commandField.setName("command");
    m_commandField.setAllowBlank(false);
    m_commandField.setFieldLabel("* " + MSGS.deviceCommandExecute());
    m_commandField.setLayoutData(layout);
    fieldSet.add(m_commandField, formData);
    m_fileUploadField = new FileUploadField();
    m_fileUploadField.setAllowBlank(true);
    m_fileUploadField.setName("file");
    m_fileUploadField.setLayoutData(layout);
    m_fileUploadField.setFieldLabel(MSGS.deviceCommandFile());
    fieldSet.add(m_fileUploadField, formData);
    m_passwordField = new TextField<String>();
    m_passwordField.setName("password");
    m_passwordField.setFieldLabel(MSGS.deviceCommandPassword());
    m_passwordField.setToolTip(MSGS.deviceCommandPasswordTooltip());
    m_passwordField.setPassword(true);
    m_passwordField.setLayoutData(layout);
    fieldSet.add(m_passwordField, formData);
    m_commandInput = m_formPanel;
    m_commandInput.mask(MSGS.deviceNoDeviceSelected());
}
Also used : FormData(com.extjs.gxt.ui.client.widget.layout.FormData) FormLayout(com.extjs.gxt.ui.client.widget.layout.FormLayout) Listener(com.extjs.gxt.ui.client.event.Listener) SelectionListener(com.extjs.gxt.ui.client.event.SelectionListener) NodeList(com.google.gwt.dom.client.NodeList) Element(com.google.gwt.user.client.Element) BaseEvent(com.extjs.gxt.ui.client.event.BaseEvent) FileUploadField(com.extjs.gxt.ui.client.widget.form.FileUploadField) MessageBoxEvent(com.extjs.gxt.ui.client.event.MessageBoxEvent) FieldSet(com.extjs.gxt.ui.client.widget.form.FieldSet) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) FormEvent(com.extjs.gxt.ui.client.event.FormEvent)

Example 5 with FileUploadField

use of com.extjs.gxt.ui.client.widget.form.FileUploadField in project kapua by eclipse.

the class FileUploadDialog method onRender.

@Override
protected void onRender(Element parent, int pos) {
    super.onRender(parent, pos);
    setLayout(new FormLayout());
    setBodyBorder(false);
    // setButtonAlign(HorizontalAlignment.CENTER); // Must be called beforehand
    setModal(true);
    setButtons("");
    setAutoWidth(true);
    setScrollMode(Scroll.AUTO);
    setHideOnButtonClick(false);
    m_formPanel = new FormPanel();
    m_formPanel.setFrame(false);
    m_formPanel.setHeaderVisible(false);
    m_formPanel.setBodyBorder(false);
    m_formPanel.setAction(m_url);
    m_formPanel.setEncoding(Encoding.MULTIPART);
    m_formPanel.setMethod(Method.POST);
    m_formPanel.setButtonAlign(HorizontalAlignment.CENTER);
    m_formPanel.addListener(Events.Submit, new Listener<FormEvent>() {

        @Override
        public void handleEvent(FormEvent be) {
            String htmlResponse = be.getResultHtml();
            if (htmlResponse == null || htmlResponse.isEmpty()) {
                MessageBox.info(MSGS.information(), MSGS.fileUploadSuccess(), null);
            } else {
                String errMsg = htmlResponse;
                int startIdx = htmlResponse.indexOf("<pre>");
                int endIndex = htmlResponse.indexOf("</pre>");
                if (startIdx != -1 && endIndex != -1) {
                    errMsg = htmlResponse.substring(startIdx + 5, endIndex);
                }
                MessageBox.alert(MSGS.error(), MSGS.fileUploadFailure() + ": " + errMsg, null);
            }
            hide();
        }
    });
    m_fileUploadField = new FileUploadField();
    m_fileUploadField.setAllowBlank(false);
    m_fileUploadField.setName("uploadedFile");
    m_fileUploadField.setFieldLabel("File");
    m_formPanel.add(m_fileUploadField);
    if (m_hiddenFields != null) {
        for (HiddenField<?> hf : m_hiddenFields) {
            m_formPanel.add(hf);
        }
    }
    // 
    // xsrfToken Hidden field
    // 
    gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

        @Override
        public void onFailure(Throwable ex) {
            FailureHandler.handle(ex);
        }

        @Override
        public void onSuccess(GwtXSRFToken token) {
            xsrfTokenField.setValue(token.getToken());
        }
    });
    xsrfTokenField = new HiddenField<String>();
    xsrfTokenField.setId("xsrfToken");
    xsrfTokenField.setName("xsrfToken");
    xsrfTokenField.setValue("");
    m_formPanel.add(xsrfTokenField);
    // 
    add(m_formPanel);
}
Also used : FormLayout(com.extjs.gxt.ui.client.widget.layout.FormLayout) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) FormEvent(com.extjs.gxt.ui.client.event.FormEvent) GwtXSRFToken(org.eclipse.kapua.app.console.shared.model.GwtXSRFToken) FileUploadField(com.extjs.gxt.ui.client.widget.form.FileUploadField)

Aggregations

FormEvent (com.extjs.gxt.ui.client.event.FormEvent)6 FileUploadField (com.extjs.gxt.ui.client.widget.form.FileUploadField)6 FormPanel (com.extjs.gxt.ui.client.widget.form.FormPanel)6 FormLayout (com.extjs.gxt.ui.client.widget.layout.FormLayout)5 FormData (com.extjs.gxt.ui.client.widget.layout.FormData)3 GwtXSRFToken (org.eclipse.kura.web.shared.model.GwtXSRFToken)3 FieldSet (com.extjs.gxt.ui.client.widget.form.FieldSet)2 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)2 GwtXSRFToken (org.eclipse.kapua.app.console.shared.model.GwtXSRFToken)2 BaseEvent (com.extjs.gxt.ui.client.event.BaseEvent)1 Listener (com.extjs.gxt.ui.client.event.Listener)1 MessageBoxEvent (com.extjs.gxt.ui.client.event.MessageBoxEvent)1 SelectionListener (com.extjs.gxt.ui.client.event.SelectionListener)1 Margins (com.extjs.gxt.ui.client.util.Margins)1 ContentPanel (com.extjs.gxt.ui.client.widget.ContentPanel)1 LayoutContainer (com.extjs.gxt.ui.client.widget.LayoutContainer)1 TabItem (com.extjs.gxt.ui.client.widget.TabItem)1 TabPanel (com.extjs.gxt.ui.client.widget.TabPanel)1 HiddenField (com.extjs.gxt.ui.client.widget.form.HiddenField)1 TextArea (com.extjs.gxt.ui.client.widget.form.TextArea)1