List of usage examples for com.google.gwt.http.client URL encode
public static String encode(String decodedURL)
From source file:org.opencms.ade.upload.client.ui.CmsUploadDialogImpl.java
License:Open Source License
/** * Creates a form that contains the file input fields and the target folder.<p> * /* w w w. j a v a2s .c om*/ * @return the form */ private FormPanel createForm() { // create a form using the POST method and multipart MIME encoding FormPanel form = new FormPanel(); form.setAction(getUploadUri()); form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); // create a panel that contains the file input fields and the target folder FlowPanel inputFieldsPanel = new FlowPanel(); int count = 0; for (CmsFileInput input : m_inputsToUpload.values()) { String filename = input.getFiles()[0].getFileName(); String fieldName = "file_" + count++; input.setName(fieldName); if (getFilesToUpload().containsKey(filename)) { inputFieldsPanel.add(input); } addHiddenField(inputFieldsPanel, fieldName + I_CmsUploadConstants.UPLOAD_FILENAME_ENCODED_SUFFIX, URL.encode(filename)); } for (String filename : getFilesToUnzip(false)) { addHiddenField(inputFieldsPanel, I_CmsUploadConstants.UPLOAD_UNZIP_FILES_FIELD_NAME, URL.encode(filename)); } addHiddenField(inputFieldsPanel, I_CmsUploadConstants.UPLOAD_TARGET_FOLDER_FIELD_NAME, getTargetFolder()); form.setWidget(inputFieldsPanel); return form; }
From source file:org.opencms.gwt.client.ui.input.upload.impl.CmsUploaderDefault.java
License:Open Source License
/** * Creates a form to submit the upload files.<p> * * @param uploadUri the upload URI//from ww w.ja v a 2 s . c om * @param targetFolder the target folder * @param isRootPath if the target folder is given as a root path * @param filesToUpload the files to upload * @param filesToUnzip the files to unzip * @return the created form panel */ private FormPanel createForm(String uploadUri, String targetFolder, boolean isRootPath, List<CmsFileInfo> filesToUpload, List<String> filesToUnzip) { // create a form using the POST method and multipart MIME encoding FormPanel form = new FormPanel(); form.setAction(uploadUri); form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); // create a panel that contains the file input fields and the target folder FlowPanel inputFieldsPanel = new FlowPanel(); int count = 0; for (CmsFileInfo info : filesToUpload) { InputElement input = info.getInputElement(); String fieldName = "file_" + count++; input.setName(fieldName); inputFieldsPanel.getElement().appendChild(input); addHiddenField(inputFieldsPanel, fieldName + I_CmsUploadConstants.UPLOAD_FILENAME_ENCODED_SUFFIX, URL.encode(info.getOverrideFileName())); } for (String filename : filesToUnzip) { addHiddenField(inputFieldsPanel, I_CmsUploadConstants.UPLOAD_UNZIP_FILES_FIELD_NAME, URL.encode(filename)); } addHiddenField(inputFieldsPanel, I_CmsUploadConstants.UPLOAD_TARGET_FOLDER_FIELD_NAME, targetFolder); addHiddenField(inputFieldsPanel, I_CmsUploadConstants.UPLOAD_IS_ROOT_PATH_FIELD_NAME, "" + isRootPath); form.setWidget(inputFieldsPanel); return form; }
From source file:org.opendatakit.common.security.client.CredentialsInfo.java
License:Apache License
public String getRequestParameters() { StringBuilder postData = new StringBuilder(); // note param pairs are separated by a '&' // and each key-value pair is separated by a '=' postData.append("username=").append(URL.encode(username)); postData.append("&"); postData.append("digestAuthHash=").append(URL.encode(digestAuthHash)); if (basicAuthHash != null && basicAuthSalt != null) { postData.append("&"); postData.append("basicAuthHash=").append(URL.encode(basicAuthHash)); postData.append("&"); postData.append("basicAuthSalt=").append(URL.encode(basicAuthSalt)); }/*from w w w. ja v a 2s. c om*/ return postData.toString(); }
From source file:org.openelis.modules.order1.client.SendoutOrderScreenUI.java
License:Open Source License
protected void orderRequestForm() { Query query;//from w w w.j a v a2s . co m QueryData field; query = new Query(); field = new QueryData(); field.setKey("ORDER_ID"); field.setQuery(manager.getIorder().getId().toString()); field.setType(QueryData.Type.INTEGER); query.setFields(field); field = new QueryData(); field.setKey("PRINTER"); field.setQuery("-view-"); field.setType(QueryData.Type.INTEGER); query.setFields(field); setBusy(Messages.get().gen_generatingReport()); RequestFormReportService.get().runReport(query, new AsyncCallback<ReportStatus>() { public void onSuccess(ReportStatus status) { String url; if (ReportStatus.Status.SAVED.equals(status.getStatus())) { url = "/openelis/openelis/report?file=" + status.getMessage(); Window.open(URL.encode(url), "OrderRequestFormReport", null); setDone(Messages.get().gen_loadCompleteMessage()); } else { setDone(status.getMessage()); } } public void onFailure(Throwable caught) { setError("Failed"); caught.printStackTrace(); Window.alert(caught.getMessage()); } }); // window.clearStatus(); }
From source file:org.openelis.modules.report.client.ReportScreen.java
License:Open Source License
public void runReport(T query) { window.setBusy(Messages.get().genReportMessage()); runReport(query, new AsyncCallback<ReportStatus>() { public void onSuccess(ReportStatus status) { String url;//from w w w .j a v a2 s . c om if (status.getStatus() == ReportStatus.Status.SAVED) { url = "/openelis/openelis/report?file=" + status.getMessage(); if (attachmentName != null) url += "&attachment=" + attachmentName; Window.open(URL.encode(url), name, null); window.setDone("Generated file " + status.getMessage()); } else { window.setDone(status.getMessage()); } } public void onFailure(Throwable caught) { window.setError("Failed"); Window.alert(caught.getMessage()); } }); }
From source file:org.openelis.modules.report.dataView1.client.DataViewScreenUI.java
License:Open Source License
/** * Calls a service method for generating a file and shows the file in the * front-end; the service method and type of file generated may vary *//* w w w. j a v a 2 s .c o m*/ private void runReport() { reportScreen.runReport(data, new AsyncCallbackUI<ReportStatus>() { @Override public void success(ReportStatus result) { String url; hideStatus(); if (result.getStatus() == ReportStatus.Status.SAVED) { url = "/openelis/openelis/report?file=" + result.getMessage(); if (reportScreen.getAttachmentName() != null) url += "&attachment=" + reportScreen.getAttachmentName(); Window.open(URL.encode(url), reportScreen.getRunReportInterface(), null); reportScreen.getWindow().setDone("Generated file " + result.getMessage()); } else { reportScreen.getWindow().setDone(result.getMessage()); } } @Override public void notFound() { hideStatus(); reportScreen.getWindow().setDone(Messages.get().gen_noRecordsFound()); } @Override public void failure(Throwable caught) { hideStatus(); reportScreen.getWindow().setError("Failed"); Window.alert(caught.getMessage()); logger.log(Level.SEVERE, caught.getMessage(), caught); } }); }
From source file:org.openelis.modules.report.secondaryLabel.client.SecondaryLabelReportScreen.java
License:Open Source License
public void runReport(ArrayList<SecondaryLabelVO> labels) { window.setBusy(Messages.get().genReportMessage()); runReport(labels, new AsyncCallback<ReportStatus>() { public void onSuccess(ReportStatus status) { String url;// ww w .j a va 2 s . c om if (status.getStatus() == ReportStatus.Status.SAVED) { url = "/openelis/openelis/report?file=" + status.getMessage(); if (attachmentName != null) url += "&attachment=" + attachmentName; Window.open(URL.encode(url), name, null); window.setDone("Generated file " + status.getMessage()); } else { window.setDone(status.getMessage()); } } public void onFailure(Throwable caught) { ValidationErrorsList e; StringBuilder sb; if (caught instanceof ValidationErrorsList) { e = (ValidationErrorsList) caught; sb = new StringBuilder(); /* * the method for printing labels in the back-end throws a * ValidationErrorsList if some labels have errors while * others can be printed; showErrors() is not used here * because the errors are shown in an alert which can't be * done with that method */ sb.append(Messages.get().secondaryLabel_errorsPrintingLabels()).append(":\n"); for (Exception ex : e.getErrorList()) sb.append(" * ").append(ex.getMessage()).append("\n"); Window.alert(sb.toString()); window.setError(Messages.get().secondaryLabel_errorsPrintingLabels()); } else { window.setError("Failed"); Window.alert(caught.getMessage()); } } }); }
From source file:org.openelis.portal.modules.dataView.client.DataViewScreen.java
License:Open Source License
/** * creates a popup that shows the progress of creating data view report *///www . j av a 2 s .c o m private void popup(DataView1VO data) { final PopupPanel statusPanel; if (statusScreen == null) statusScreen = new StatusBarPopupScreenUI(); statusScreen.setStatus(null); /* * initialize and show the popup screen */ statusPanel = new PopupPanel(); statusPanel.setSize("450px", "125px"); statusScreen.setSize("450px", "125px"); statusPanel.setWidget(statusScreen); statusPanel.setPopupPosition(this.getAbsoluteLeft() + 50, this.getAbsoluteTop() + 50); statusPanel.setModal(true); statusPanel.show(); /* * Create final reports. Hide popup when database is updated * successfully or error is thrown. */ DataViewService.get().runReportForPortal(data, new AsyncCallback<ReportStatus>() { @Override public void onSuccess(ReportStatus result) { if (result.getStatus() == ReportStatus.Status.SAVED) { String url = "/openelisweb/openelisweb/report?file=" + result.getMessage(); Window.open(URL.encode(url), "DataView", "resizable=yes"); } window.clearStatus(); statusPanel.hide(); statusScreen.setStatus(null); } @Override public void onFailure(Throwable caught) { window.clearStatus(); statusPanel.hide(); statusScreen.setStatus(null); if (caught instanceof NotFoundException) window.setError(Messages.get().dataView_error_noResults()); else Window.alert(caught.getMessage()); } }); /* * refresh the status of creating the reports every second, until the * process successfully completes or is aborted because of an error */ Timer timer = new Timer() { public void run() { ReportStatus status; try { status = DataViewService.get().getStatus(); /* * the status only needs to be refreshed while the status * panel is showing because once the job is finished, the * panel is closed */ if (statusPanel.isShowing()) { statusScreen.setStatus(status); this.schedule(50); } } catch (Exception e) { Window.alert(e.getMessage()); remote.log(Level.SEVERE, e.getMessage(), e); } } }; timer.schedule(50); }
From source file:org.openelis.ui.screen.ReportScreen.java
License:Open Source License
/** * Provides a more generic interface to run reports so that screens not * implementing ReportScreen can utilize this functionality too *///www . j a va 2s . c o m public void runReport(T rpc) { window.setBusy("genReportMessage"); runReport(rpc, new AsyncCallback<ReportStatus>() { public void onSuccess(ReportStatus status) { String url; if (status.getStatus() == ReportStatus.Status.SAVED) { url = "/timetracker/report?file=" + status.getMessage(); if (attachmentName != null) url += "&attachment=" + attachmentName; Window.open(URL.encode(url), name, null); window.setDone("Generated file " + status.getMessage()); } else { window.setDone(status.getMessage()); } } public void onFailure(Throwable caught) { window.setError("Failed"); Window.alert(caught.getMessage()); } }); }
From source file:org.openmobster.core.cloud.console.client.ui.apn.DownloadCertificateDialog.java
License:Open Source License
public Canvas render() { this.initComplete(this); Window winModal = new Window(); winModal.setWidth(360);// w w w. jav a 2 s . c om winModal.setHeight(200); winModal.setTitle("Download Push Certificate"); winModal.setShowMinimizeButton(false); winModal.setIsModal(true); winModal.setShowModalMask(true); winModal.centerInPage(); winModal.setShowCloseButton(false); VLayout formLayout = new VLayout(); //Create the Form form = new DynamicForm(); form.setHeight100(); form.setWidth100(); form.setPadding(5); form.setLayoutAlign(VerticalAlignment.BOTTOM); form.setTarget(this.title()); form.setEncoding(Encoding.MULTIPART); form.setAction(GWT.getModuleBaseURL() + "apn"); this.appIdText = new StaticTextItem(); this.appIdText.setTitle("App Id"); this.appIdText.setValue(record.getAppId()); this.fileItem = new UploadItem("certificate"); this.fileItem.setTitle("Replace Cert"); this.fileItem.setWidth(300); this.password = new PasswordItem("password"); this.password.setTitle("Password"); Button downloadButton = new Button("Download Cert"); downloadButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent e) { String appId = URL.encode(record.getAppId()); com.google.gwt.user.client.Window .open(GWT.getModuleBaseURL() + "apn/certificate/download?appid=" + appId, "_blank", null); } }); Button replaceButton = new Button("Replace Cert"); replaceButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent e) { Object obj = fileItem.getDisplayValue(); Object passwordVal = password.getValue(); if (obj != null && passwordVal != null) { SC.showPrompt("Upload Certificate", "Upload in Progress"); form.submitForm(); } else { SC.say("All fields are required"); } } }); Button pushButton = new Button("Send Test Push"); pushButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent e) { DownloadCertificateDialog.this.startTestPush(); } }); Button stopPushButton = new Button("Stop Push"); stopPushButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent e) { DownloadCertificateDialog.this.stopPush(); } }); Button close = new Button(); close.setTitle("Close"); close.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { FlowServiceRegistry.getTransitionService().closeActiveWindow(); } }); form.setFields(this.appIdText, this.fileItem, this.password); formLayout.addChild(form); //Button bar HLayout toolbar = new HLayout(); toolbar.setAlign(Alignment.CENTER); toolbar.addMember(downloadButton); toolbar.addMember(replaceButton); toolbar.addMember(pushButton); //Second Button Bar HLayout toolbar2 = new HLayout(); toolbar2.setAlign(Alignment.CENTER); toolbar2.addMember(stopPushButton); toolbar2.addMember(close); NamedFrame frame = new NamedFrame(this.title()); frame.setWidth("1px"); frame.setHeight("1px"); frame.setVisible(false); formLayout.addMember(frame); winModal.addItem(formLayout); winModal.addItem(toolbar); winModal.addItem(toolbar2); return winModal; }