Search in sources :

Example 61 with FormLayout

use of com.extjs.gxt.ui.client.widget.layout.FormLayout in project kapua by eclipse.

the class SSLFileUploadDialog method onRender.

@Override
protected void onRender(Element parent, int pos) {
    super.onRender(parent, pos);
    setLayout(new FormLayout());
    setBodyBorder(false);
    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>() {

        HiddenField<Boolean> success = new HiddenField<Boolean>();

        @Override
        public void handleEvent(FormEvent be) {
            String htmlResponse = be.getResultHtml();
            if (htmlResponse == null || htmlResponse.isEmpty()) {
                success = new HiddenField<Boolean>();
                success.setName("success");
                success.setValue(true);
                m_hiddenFields.set(0, success);
            } 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);
                success = new HiddenField<Boolean>();
                success.setName("success");
                success.setValue(false);
                m_hiddenFields.set(0, success);
            }
            hide();
        }
    });
    m_fileUploadFieldCert = new FileUploadField();
    m_fileUploadFieldCert.setAllowBlank(false);
    m_fileUploadFieldCert.setName("uploadedSSLCert");
    m_fileUploadFieldCert.setFieldLabel("SSL Certificate");
    m_formPanel.add(m_fileUploadFieldCert);
    m_fileUploadFieldKey = new FileUploadField();
    m_fileUploadFieldKey.setAllowBlank(false);
    m_fileUploadFieldKey.setName("uploadedSSLKey");
    m_fileUploadFieldKey.setFieldLabel("SSL Key");
    m_formPanel.add(m_fileUploadFieldKey);
    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("");
    // Add the xsrf hidden field to the form panel
    m_formPanel.add(xsrfTokenField);
    add(m_formPanel);
}
Also used : FormLayout(com.extjs.gxt.ui.client.widget.layout.FormLayout) HiddenField(com.extjs.gxt.ui.client.widget.form.HiddenField) GwtXSRFToken(org.eclipse.kapua.app.console.shared.model.GwtXSRFToken) FileUploadField(com.extjs.gxt.ui.client.widget.form.FileUploadField) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) FormEvent(com.extjs.gxt.ui.client.event.FormEvent)

Aggregations

FormLayout (com.extjs.gxt.ui.client.widget.layout.FormLayout)61 FieldSet (com.extjs.gxt.ui.client.widget.form.FieldSet)37 FormPanel (com.extjs.gxt.ui.client.widget.form.FormPanel)29 FormData (com.extjs.gxt.ui.client.widget.layout.FormData)26 Button (com.extjs.gxt.ui.client.widget.button.Button)24 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)19 FlowLayout (com.extjs.gxt.ui.client.widget.layout.FlowLayout)18 SelectionListener (com.extjs.gxt.ui.client.event.SelectionListener)15 GPSecureStringTextField (org.geosdi.geoplatform.gui.configuration.GPSecureStringTextField)15 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)12 BaseEvent (com.extjs.gxt.ui.client.event.BaseEvent)11 LabelField (com.extjs.gxt.ui.client.widget.form.LabelField)10 NumberField (com.extjs.gxt.ui.client.widget.form.NumberField)9 CheckBox (com.extjs.gxt.ui.client.widget.form.CheckBox)7 TextField (com.extjs.gxt.ui.client.widget.form.TextField)7 ComponentEvent (com.extjs.gxt.ui.client.event.ComponentEvent)6 Margins (com.extjs.gxt.ui.client.util.Margins)6 Label (com.extjs.gxt.ui.client.widget.Label)6 Radio (com.extjs.gxt.ui.client.widget.form.Radio)6 RadioGroup (com.extjs.gxt.ui.client.widget.form.RadioGroup)6