List of usage examples for com.google.gwt.user.client.ui FormPanel ENCODING_URLENCODED
String ENCODING_URLENCODED
To view the source code for com.google.gwt.user.client.ui FormPanel ENCODING_URLENCODED.
Click Source Link
From source file:org.rstudio.studio.client.server.remote.RemoteServerAuth.java
License:Open Source License
public void updateCredentials(final ServerRequestCallback<Integer> requestCallback) { // safely cleanup any previously active update credentials forms safeCleanupPreviousUpdateCredentials(); // create a hidden form panel to submit the update credentials to // (we do this so GWT manages the trickiness associated with // managing and reading the contents of a hidden iframe) final FormPanel updateCredentialsForm = new FormPanel(); updateCredentialsForm.setMethod(FormPanel.METHOD_GET); updateCredentialsForm.setEncoding(FormPanel.ENCODING_URLENCODED); // form url//from w w w . ja v a 2s . co m String url = remoteServer_.getApplicationURL("auth-update-credentials"); updateCredentialsForm.setAction(url); // request log entry (fake up a json rpc method call to conform // to the data format expected by RequestLog String requestId = Integer.toString(Random.nextInt()); String requestData = createRequestData(); final RequestLogEntry logEntry = RequestLog.log(requestId, requestData); // form submit complete handler updateCredentialsForm.addSubmitCompleteHandler(new SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { // parse the results String results = event.getResults(); RpcResponse response = RpcResponse.parse(event.getResults()); if (response != null) { logEntry.logResponse(ResponseType.Normal, results); // check for error RpcError rpcError = response.getError(); if (rpcError != null) { if (rpcError.getCode() == RpcError.METHOD_NOT_FOUND) { requestCallback.onResponseReceived(new Integer(CREDENTIALS_UPDATE_UNSUPPORTED)); } else { requestCallback.onError(new RemoteServerError(rpcError)); } } else // must be a valid response { Bool authenticated = response.getResult(); if (authenticated.getValue()) { requestCallback.onResponseReceived(new Integer(CREDENTIALS_UPDATE_SUCCESS)); } else { requestCallback.onResponseReceived(new Integer(CREDENTIALS_UPDATE_FAILURE)); } } } else // error parsing results { logEntry.logResponse(ResponseType.Error, results); // form message String msg = "Error parsing results: " + (results != null ? results : "(null)"); // we don't expect this so debug log to flag our attention Debug.log("UPDATE CREDENTIALS: " + msg); // return the error RpcError rpcError = RpcError.create(RpcError.PARSE_ERROR, msg); requestCallback.onError(new RemoteServerError(rpcError)); } // remove the hidden form (from both last-ditch list and DOM) previousUpdateCredentialsForms_.remove(updateCredentialsForm); Scheduler.get().scheduleDeferred(new ScheduledCommand() { public void execute() { RootPanel.get().remove(updateCredentialsForm); } }); } }); // add the (hidden) form panel to the document and last ditch list RootPanel.get().add(updateCredentialsForm, -1000, -1000); previousUpdateCredentialsForms_.add(updateCredentialsForm); // submit the form updateCredentialsForm.submit(); }
From source file:org.utgenome.gwt.utgb.client.track.lib.NavigatorTrack.java
License:Apache License
public NavigatorTrack() { super("NavigatorTrack"); panel.setStyleName("toolbox"); panel.setWidth("100%"); speciesBox.addChangeHandler(new PropertyChangeHandler(UTGBProperty.SPECIES, speciesBox)); revisionBox.addChangeHandler(new PropertyChangeHandler(UTGBProperty.REVISION, revisionBox)); regionBox.addKeyUpHandler(new SequenceRangeChangeListner()); targetBox.addKeyUpHandler(new KeyUpHandler() { public void onKeyUp(KeyUpEvent e) { int keyCode = e.getNativeKeyCode(); if (keyCode == KeyCodes.KEY_ENTER || keyCode == KeyCodes.KEY_TAB) { getTrackGroup().getPropertyWriter().setProperty(UTGBProperty.TARGET, targetBox.getText()); }//from w w w . j a v a 2s . c om } }); targetBox.setWidth("100px"); // value selectors hp.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); hp.add(new FormLabel("Species")); hp.add(speciesBox); hp.add(new FormLabel("Ref.")); hp.add(revisionBox); hp.add(new FormLabel("Chr.")); hp.add(targetBox); // window locator regionBox.setWidth("160px"); hp2.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); hp2.add(new FormLabel("Region")); hp2.add(regionBox); Button strandSwitch = new Button("reverse"); Style.margin(strandSwitch, Style.LEFT, 2); Style.border(strandSwitch, 2, Style.BORDER_OUTSET, "white"); strandSwitch.addClickHandler(new ClickHandler() { public void onClick(ClickEvent e) { isPlusStrand = !isPlusStrand; TrackWindow window = getTrackGroup().getTrackWindow(); if (isPlusStrand) { getTrackGroup().setTrackWindowLocation(window.getEndOnGenome(), window.getStartOnGenome()); } else { getTrackGroup().setTrackWindowLocation(window.getEndOnGenome(), window.getStartOnGenome()); } } }); // TODO reverse button //hp2.add(strandSwitch); hp2.add(new ScrollButtonSet()); // save view final FormPanel saveViewForm = new FormPanel(); saveViewForm.setAction(GWT.getModuleBaseURL() + "utgb-core/EchoBackView"); saveViewForm.setEncoding(FormPanel.ENCODING_URLENCODED); saveViewForm.setMethod(FormPanel.METHOD_POST); final Hidden viewData = new Hidden("view"); final Hidden time = new Hidden("time"); final Button saveButton = new Button("save view"); HorizontalPanel formLayout = new HorizontalPanel(); formLayout.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); viewData.setVisible(false); formLayout.add(viewData); formLayout.add(time); formLayout.add(saveButton); saveButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent e) { XMLWriter xmlWriter = new XMLWriter(); getTrackGroup().toXML(xmlWriter); String view = xmlWriter.toString(); viewData.setValue(view); // send the time stamp Date today = new Date(); time.setValue(Long.toString(today.getTime())); saveViewForm.submit(); } }); saveViewForm.add(formLayout); DOM.setStyleAttribute(saveViewForm.getElement(), "margin", "0"); hp.add(saveViewForm); Button loadButton = new Button("load view"); loadButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent e) { getTrackGroup().insertTrack(new ViewLoaderTrack(), getTrackGroup().getTrackIndex(_self) + 1); } }); hp.add(loadButton); }
From source file:therandomhomepage.mainclient.FeedbackPanel.java
License:Apache License
public FeedbackPanel() { NamedFrame mailFrame = new NamedFrame("mailFrame"); mailFrame.setVisible(false);//from www . j a v a2 s . co m final FormPanel form = new FormPanel(mailFrame); form.setAction("/php/sendMail.php"); form.setMethod(FormPanel.METHOD_GET); form.setEncoding(FormPanel.ENCODING_URLENCODED); VerticalPanel panel = new VerticalPanel(); panel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); panel.setVerticalAlignment(VerticalPanel.ALIGN_TOP); panel.add(form); panel.add(mailFrame); initWidget(panel); table = new FlexTable(); table.addStyleName("divBlock"); table.addStyleName("feedbackForm"); table.setWidget(1, 0, new HTML("<h3>Feedback</h3>")); table.setWidget(2, 0, new Label("Name: ")); table.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP); TextBox txtName = new TextBox(); txtName.setName("txtName"); table.setWidget(2, 1, txtName); table.setWidget(3, 0, new Label("Email: ")); table.getFlexCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_TOP); txtEmail = new TextBox(); txtEmail.setName("txtEmail"); table.setWidget(3, 1, txtEmail); table.setWidget(4, 0, new Label("Subject: ")); table.getFlexCellFormatter().setVerticalAlignment(3, 0, HasVerticalAlignment.ALIGN_TOP); ListBox subject = new ListBox(); subject.setName("selSubject"); subject.addItem("General", "General"); subject.addItem("Comments", "Comments"); subject.addItem("Suggestion", "Suggestion"); subject.addItem("Bug report", "Bug report"); subject.addItem("Others", "Others"); table.setWidget(4, 1, subject); table.setWidget(5, 0, new Label("Message: ")); table.getFlexCellFormatter().setVerticalAlignment(4, 0, HasVerticalAlignment.ALIGN_TOP); txtMessage = new TextArea(); txtMessage.setName("txtMessage"); txtMessage.setCharacterWidth(50); txtMessage.setVisibleLines(8); table.setWidget(5, 1, txtMessage); btnSubmit = new Button("Submit", new ClickListener() { public void onClick(Widget sender) { form.submit(); } }); table.setWidget(6, 0, btnSubmit); form.add(table); form.addFormHandler(new FormHandler() { public void onSubmitComplete(FormSubmitCompleteEvent event) { //ignore this } public void onSubmit(FormSubmitEvent event) { if (txtEmail.getText().trim().length() == 0) { Window.alert("Please provide your email address !"); event.setCancelled(true); txtEmail.setFocus(true); } else if (txtMessage.getText().trim().length() == 0) { Window.alert("Please provide feedback !"); event.setCancelled(true); txtMessage.setFocus(true); } else { HTML thanksHTML = new HTML( "<b class=\"thanks\">We really appreciate your feedback. Thanks a lot !</b>"); table.setWidget(0, 1, thanksHTML); btnSubmit.setEnabled(false); } } }); }