List of usage examples for com.google.gwt.user.client.ui FormPanel METHOD_POST
String METHOD_POST
To view the source code for com.google.gwt.user.client.ui FormPanel METHOD_POST.
Click Source Link
From source file:org.kaaproject.kaa.server.admin.client.mvp.view.widget.FileUploadForm.java
License:Apache License
public FileUploadForm() { this.setEncoding(FormPanel.ENCODING_MULTIPART); this.setMethod(FormPanel.METHOD_POST); fu.setName(GUID.get());/*ww w. java2 s. com*/ fu.setHeight("30px"); this.add(fu); addSubmitHandler(new FormPanel.SubmitHandler() { public void onSubmit(SubmitEvent event) { if ("".equalsIgnoreCase(fu.getFilename())) { event.cancel(); } } }); this.setAction(GWT.getModuleBaseURL() + KAA_FILE_UPLOAD_SERVLET_PATH); }
From source file:org.kie.guvnor.commons.ui.client.widget.AttachmentFileWidget.java
License:Apache License
public AttachmentFileWidget() { form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() { @Override/*from www .jav a2 s . c om*/ public void onSubmitComplete(final FormPanel.SubmitCompleteEvent event) { if ("OK".equalsIgnoreCase(event.getResults())) { executeCallback(successCallback); Window.alert(CommonConstants.INSTANCE.UploadSuccess()); } else { executeCallback(errorCallback); Window.alert(CommonConstants.INSTANCE.UploadFailure0(event.getResults())); } } }); final FileUpload up = new FileUpload(); up.setName(FileManagerFields.UPLOAD_FIELD_NAME_ATTACH); fields.add(up); form.add(fields); initWidget(form); }
From source file:org.kie.guvnor.dtablexls.client.editor.AttachmentFileWidget.java
License:Apache License
protected void initWidgets() { form = new FormPanel(); form.setAction(GWT.getModuleBaseURL() + "dtablexls/file"); form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); FileUpload up = new FileUpload(); up.setName(HTMLFileManagerFields.UPLOAD_FIELD_NAME_ATTACH); HorizontalPanel fields = new HorizontalPanel(); if (fullPath == null) { fields.add(getHiddenField(HTMLFileManagerFields.FORM_FIELD_PATH, contextPath.toURI())); fields.add(getHiddenField(HTMLFileManagerFields.FORM_FIELD_NAME, fileName)); } else {//ww w.j a v a 2s.c o m fields.add(getHiddenField(HTMLFileManagerFields.FORM_FIELD_FULL_PATH, fullPath.toURI())); } Button ok = new Button("upload"); ok.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { showUploadingBusy(); submitUpload(); } }); fields.add(up); fields.add(ok); form.add(fields); initWidget(form); }
From source file:org.kie.guvnor.m2repo.client.editor.AttachmentFileWidget.java
License:Apache License
protected void initWidgets() { form = new FormPanel(); form.setAction(GWT.getModuleBaseURL() + "file"); form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); FileUpload up = new FileUpload(); up.setName(HTMLFileManagerFields.UPLOAD_FIELD_NAME_ATTACH); HorizontalPanel fields = new HorizontalPanel(); fields.add(getHiddenField(HTMLFileManagerFields.FORM_FIELD_PATH, "uuid")); Button ok = new Button("upload"); ok.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { showUploadingBusy();//from ww w . jav a 2 s .c om submitUpload(); } }); fields.add(up); fields.add(ok); /* Button dl = new Button( "Download" ); //dl.setEnabled( this.asset.getVersionNumber() > 0 ); dl.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { Window.open( GWT.getModuleBaseURL() + "file?" + HTMLFileManagerFields.FORM_FIELD_UUID + "=" + "uuid", "downloading", "resizable=no,scrollbars=yes,status=no" ); } } ); */ form.add(fields); initWidget(form); }
From source file:org.kie.guvnor.scorecardxls.client.editor.AttachmentFileWidget.java
License:Apache License
protected void initWidgets() { form = new FormPanel(); form.setAction(GWT.getModuleBaseURL() + "scorecardxls/file"); form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); FileUpload up = new FileUpload(); up.setName(HTMLFileManagerFields.UPLOAD_FIELD_NAME_ATTACH); HorizontalPanel fields = new HorizontalPanel(); if (fullPath == null) { fields.add(getHiddenField(HTMLFileManagerFields.FORM_FIELD_PATH, contextPath.toURI())); fields.add(getHiddenField(HTMLFileManagerFields.FORM_FIELD_NAME, fileName)); } else {/* ww w .jav a 2 s.c o m*/ fields.add(getHiddenField(HTMLFileManagerFields.FORM_FIELD_FULL_PATH, fullPath.toURI())); } Button ok = new Button("upload"); ok.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { showUploadingBusy(); submitUpload(); } }); fields.add(up); fields.add(ok); form.add(fields); initWidget(form); }
From source file:org.kie.uberfire.plugin.client.widget.media.MediaLibraryWidget.java
License:Apache License
@PostConstruct public void init() { fileUpload = createFileUpload();//from w ww.ja va 2 s. c o m initWidget(uiBinder.createAndBindUi(this)); form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); form.addSubmitHandler(new FormPanel.SubmitHandler() { @Override public void onSubmit(final FormPanel.SubmitEvent event) { final String fileName = fileUpload.getFilename(); if (isNullOrEmpty(fileName)) { event.cancel(); } } private boolean isNullOrEmpty(final String fileName) { return fileName == null || "".equals(fileName); } }); form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() { public void onSubmitComplete(final FormPanel.SubmitCompleteEvent event) { if ("OK".equalsIgnoreCase(event.getResults())) { Window.alert("Upload Success"); } else if ("FAIL".equalsIgnoreCase(event.getResults())) { Window.alert("Upload Failed"); } else if ("FAIL - ALREADY EXISTS".equalsIgnoreCase(event.getResults())) { Window.alert("File already exists"); } } }); }
From source file:org.kie.workbench.common.forms.jbpm.client.document.DocumentFieldRendererViewImpl.java
License:Apache License
protected void initForm() { documentForm.clear();/* w ww . j a va 2s .co m*/ uploader = new FileUpload(() -> { if (uploader.getFilename() != null && !uploader.getFilename().isEmpty()) { documentForm.submit(); } }); uploader.setName("document"); documentForm.setEncoding(FormPanel.ENCODING_MULTIPART); documentForm.setMethod(FormPanel.METHOD_POST); documentForm.setAction(UPLOAD_FILE_SERVLET_URL_PATTERN); formEncoder.addUtf8Charset(documentForm); documentForm.add(uploader); documentForm.addSubmitCompleteHandler(event -> { onSubmit(event.getResults()); }); }
From source file:org.kie.workbench.common.widgets.client.widget.AttachmentFileWidget.java
License:Apache License
void setup(boolean addFileUpload) { up = createUploadWidget(addFileUpload); form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); formEncoder.addUtf8Charset(form); // Validation is not performed in a SubmitHandler as it fails to be invoked with GWT-Bootstrap3. See:- // - https://issues.jboss.org/browse/GUVNOR-2302 and // - the underlying cause https://github.com/gwtbootstrap3/gwtbootstrap3/issues/375 // Validation is now performed prior to the form being submitted. form.addSubmitCompleteHandler(new Form.SubmitCompleteHandler() { @Override/*w w w.j a v a2s . c o m*/ public void onSubmitComplete(final Form.SubmitCompleteEvent event) { if ("OK".equalsIgnoreCase(event.getResults())) { executeCallback(successCallback); showMessage(CommonConstants.INSTANCE.UploadSuccess()); } else { executeCallback(errorCallback); if (event.getResults().contains("org.uberfire.java.nio.file.FileAlreadyExistsException")) { showMessage(org.uberfire.ext.widgets.common.client.resources.i18n.CommonConstants.INSTANCE .ExceptionFileAlreadyExists0(fieldFileName.getText())); } else if (event.getResults().contains("DecisionTableParseException")) { showMessage(CommonConstants.INSTANCE.UploadGenericError()); } else { showMessage(org.uberfire.ext.widgets.common.client.resources.i18n.CommonConstants.INSTANCE .ExceptionGeneric0(event.getResults())); } } reset(); } }); fields.add(up); fields.add(fieldFilePath); fields.add(fieldFileName); fields.add(fieldFileFullPath); fields.add(fieldFileOperation); form.add(fields); initWidget(form); }
From source file:org.kuali.continuity.admin.main.client.Location.java
License:Educational Community License
protected void doExtraSectionLoad() { // init form//from w ww.ja va2 s. c o m final VerticalPanel vPanel = new VerticalPanel(); final FormPanel formPanel = new FormPanel(); formPanel.setEncoding(FormPanel.ENCODING_MULTIPART); formPanel.setMethod(FormPanel.METHOD_POST); formPanel.setAction(Window.Location.getProtocol() + "//" + Window.Location.getHost() + "/continuity/admin/customImageUpload"); // set form handler formPanel.addFormHandler(new FormHandler() { public void onSubmit(FormSubmitEvent event) { // event.setCancelled(true); } public void onSubmitComplete(FormSubmitCompleteEvent event) { boolean isRestore = restore.getValue().equals("true"); if (uiImageEnum.getValue().equals("BEGIN")) { imgRestoreButton1.setVisible(!isRestore); } else if (uiImageEnum.getValue().equals("BEGIN_TEXT")) { imgRestoreButton2.setVisible(!isRestore); } else if (uiImageEnum.getValue().equals("BANNER")) { imgRestoreButton3.setVisible(!isRestore); } else if (uiImageEnum.getValue().equals("BANNER_TEXT")) { imgRestoreButton4.setVisible(!isRestore); } csrfToken.setValue(Cookies.getCookie(CSRF_TOKEN)); String message = isRestore ? "Default image restored!" : "Custom image upload completed!"; Window.alert(message); } }); // custom image labels Label lblImg1 = new Label("Entry screen top image:"); Label lblImg2 = new Label("Entry screen bottom image:"); Label lblImg3 = new Label("Banner left image:"); Label lblImg4 = new Label("Banner right image:"); Label lblImgDim1 = new Label("Recommended dimensions: 700 pixels x 200 pixels"); Label lblImgDim2 = new Label("Recommended dimensions: 700 pixels x 100 pixels"); Label lblImgDim3 = new Label("Recommended height: 80 pixels"); Label lblImgDim4 = new Label("Recommended height: 80 pixels"); // styles lblImg1.setStyleName("gwt-HTML-location-bold"); lblImg2.setStyleName("gwt-HTML-location-bold"); lblImg3.setStyleName("gwt-HTML-location-bold"); lblImg4.setStyleName("gwt-HTML-location-bold"); lblImgDim1.setStyleName("gwt-HTML-location"); lblImgDim2.setStyleName("gwt-HTML-location"); lblImgDim3.setStyleName("gwt-HTML-location"); lblImgDim4.setStyleName("gwt-HTML-location"); // entry fields imgInstallButton1.setStyleName("ButtonClass"); imgInstallButton2.setStyleName("ButtonClass"); imgInstallButton3.setStyleName("ButtonClass"); imgInstallButton4.setStyleName("ButtonClass"); imgRestoreButton1.setStyleName("ButtonClass"); imgRestoreButton2.setStyleName("ButtonClass"); imgRestoreButton3.setStyleName("ButtonClass"); imgRestoreButton4.setStyleName("ButtonClass"); imgUpload1.setStyleName("ButtonClass"); imgUpload2.setStyleName("ButtonClass"); imgUpload3.setStyleName("ButtonClass"); imgUpload4.setStyleName("ButtonClass"); imgUpload1.setWidth("300px"); imgUpload2.setWidth("300px"); imgUpload3.setWidth("300px"); imgUpload4.setWidth("300px"); imgUpload1.setName("uploadedImg1"); imgUpload2.setName("uploadedImg2"); imgUpload3.setName("uploadedImg3"); imgUpload4.setName("uploadedImg4"); // construct table FlexTable imageTable = new FlexTable(); imageTable.setStylePrimaryName("location-form"); imageTable.getFlexCellFormatter().setColSpan(0, 0, 3); imageTable.setWidget(0, 0, lblImg1); imageTable.getFlexCellFormatter().setColSpan(1, 0, 3); imageTable.setWidget(1, 0, lblImgDim1); imageTable.setWidget(2, 0, imgUpload1); imageTable.setWidget(2, 1, imgInstallButton1); imageTable.setWidget(2, 2, imgRestoreButton1); imageTable.getFlexCellFormatter().setColSpan(3, 0, 3); imageTable.setWidget(3, 0, lblImg2); imageTable.getFlexCellFormatter().setColSpan(4, 0, 3); imageTable.setWidget(4, 0, lblImgDim2); imageTable.setWidget(5, 0, imgUpload2); imageTable.setWidget(5, 1, imgInstallButton2); imageTable.setWidget(5, 2, imgRestoreButton2); imageTable.getFlexCellFormatter().setColSpan(6, 0, 3); imageTable.setWidget(6, 0, lblImg3); imageTable.getFlexCellFormatter().setColSpan(7, 0, 3); imageTable.setWidget(7, 0, lblImgDim3); imageTable.setWidget(8, 0, imgUpload3); imageTable.setWidget(8, 1, imgInstallButton3); imageTable.setWidget(8, 2, imgRestoreButton3); imageTable.getFlexCellFormatter().setColSpan(9, 0, 3); imageTable.setWidget(9, 0, lblImg4); imageTable.getFlexCellFormatter().setColSpan(10, 0, 3); imageTable.setWidget(10, 0, lblImgDim4); imageTable.setWidget(11, 0, imgUpload4); imageTable.setWidget(11, 1, imgInstallButton4); imageTable.setWidget(11, 2, imgRestoreButton4); imageTable.setWidget(12, 0, systemDomainId); imageTable.setWidget(12, 1, restore); imageTable.setWidget(12, 2, uiImageEnum); // button click listener imgInstallButton1.addClickListener(new ClickListener() { public void onClick(final Widget sender) { customImageFormSubmit(formPanel, imgUpload1, false, "BEGIN"); } }); imgInstallButton2.addClickListener(new ClickListener() { public void onClick(final Widget sender) { customImageFormSubmit(formPanel, imgUpload2, false, "BEGIN_TEXT"); } }); imgInstallButton3.addClickListener(new ClickListener() { public void onClick(final Widget sender) { customImageFormSubmit(formPanel, imgUpload3, false, "BANNER"); } }); imgInstallButton4.addClickListener(new ClickListener() { public void onClick(final Widget sender) { customImageFormSubmit(formPanel, imgUpload4, false, "BANNER_TEXT"); } }); imgRestoreButton1.addClickListener(new ClickListener() { public void onClick(final Widget sender) { customImageFormSubmit(formPanel, imgUpload1, true, "BEGIN"); } }); imgRestoreButton2.addClickListener(new ClickListener() { public void onClick(final Widget sender) { customImageFormSubmit(formPanel, imgUpload2, true, "BEGIN_TEXT"); } }); imgRestoreButton3.addClickListener(new ClickListener() { public void onClick(final Widget sender) { customImageFormSubmit(formPanel, imgUpload3, true, "BANNER"); } }); imgRestoreButton4.addClickListener(new ClickListener() { public void onClick(final Widget sender) { customImageFormSubmit(formPanel, imgUpload4, true, "BANNER_TEXT"); } }); // vertical panel vPanel.setStylePrimaryName("location-shib-form"); vPanel.add(new HTML("<h1>Upload Custom Images</h1>")); vPanel.add(new HTML( "To upload custom images, highlight the row on the grid then use the entry form below to upload your images.")); // add table to form formPanel.add(imageTable); vPanel.add(formPanel); // dock form // dockPanel.add(vPanel, DockPanel.SOUTH); RootPanel rootPanel = RootPanel.get("gwtRoot"); rootPanel.add(vPanel); }
From source file:org.kuali.student.core.document.ui.client.widgets.documenttool.DocumentTool.java
License:Educational Community License
@Override protected Widget createWidget() { //This section title code does not seem consistent with other sections (i.e: of CourseProposal) // section title is now instead displayed based on verticalSectionView in createUploadForm() /*SectionTitle viewTitle = SectionTitle.generateH2Title(getTitle()); // www . j a v a 2 s. com viewTitle.addStyleName("ks-layout-header"); layout.add(viewTitle);*/ layout.add(saveWarning); saveWarning.setVisible(false); buttonPanel.setButtonText(OkEnum.Ok, "Upload"); buttonPanel.getButton(OkEnum.Ok).setStyleName(ButtonStyle.SECONDARY.getStyle()); uploadList.add(createUploadForm()); form.setWidget(uploadList); form.setMethod(FormPanel.METHOD_POST); form.setEncoding(FormPanel.ENCODING_MULTIPART); buttonPanel.setContent(form); if (showAllLink != null) { layout.add(showAllLink); } layout.add(buttonPanel); layout.add(documentList); documentList.setVisible(false); buttonPanel.setVisible(false); SectionTitle sectionTitle = SectionTitle.generateH2Title("Upload Status"); progressWindow.setNonCaptionHeader(sectionTitle); progressPanel.add(progressLabel); progressPanel.add(progressBar); progressPanel.add(fileProgressTable); progressBar.setWidth("400px"); progressBar.setTextFormatter(new TextFormatter() { @Override protected String getText(ProgressBar bar, double curProgress) { String result; NumberFormat nf = NumberFormat.getFormat("#.##"); if (curProgress == bar.getMaxProgress()) { result = "Total Uploaded: " + nf.format(curProgress) + "kb"; } else if (curProgress == 0 || bar.getMaxProgress() == 0) { result = ""; } else { String curProgressString; String maxProgressString; if (curProgress < 1024) { curProgressString = nf.format(curProgress) + "kb"; } else { curProgressString = nf.format(curProgress / 1024) + "mb"; } if (bar.getMaxProgress() < 1024) { maxProgressString = nf.format(bar.getMaxProgress()) + "kb"; } else { maxProgressString = nf.format((bar.getMaxProgress()) / 1024) + "mb"; } result = curProgressString + " out of " + maxProgressString; } return result; } }); progressBar.setHeight("30px"); progressPanel.add(progressButtons); progressPanel.setWidth("500px"); progressWindow.setWidget(progressPanel); progressWindow.setSize(520, 270); return layout; }