Advertisement
Guest User

gwt class

a guest
Jan 12th, 2016
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Entry point classes define <code>onModuleLoad()</code>.
  3.  */
  4. public class Testdialog2 implements EntryPoint {
  5.  
  6.     /**
  7.      * This is the entry point method.
  8.      */
  9.     public void onModuleLoad() {
  10.  
  11.         final TextBox nameField = new TextBox();
  12.         final Button sendButton = new Button("Send");
  13.         sendButton.addStyleName("sendButton");
  14.         sendButton.addClickHandler(new ClickHandler() {
  15.  
  16.             @Override
  17.             public void onClick(ClickEvent event) {
  18.                 sendMessage(nameField.getValue());
  19.             }
  20.         });
  21.  
  22.         nameField.setText("Message To Send Via postMessage");
  23.  
  24.         RootPanel.get().add(sendButton);
  25.         RootPanel.get().add(nameField);
  26.  
  27.         nameField.setFocus(true);
  28.         nameField.selectAll();
  29.  
  30.     }
  31.  
  32.     /**
  33.      * Specifies what the origin of otherWindow must be for the event to be dispatched, either as the literal string "*"
  34.      * (indicating no * preference) or as a URI. If at the time the event is scheduled to be dispatched the scheme,
  35.      * hostname, or port of otherWindow's document does not match that provided in targetOrigin, the event will not be dispatched;
  36.      * only if all three match will the event be dispatched. This mechanism provides control over where messages are sent;
  37.      * for example, if postMessage was used to transmit a password, it would be absolutely critical that this
  38.      * argument be a URI whose origin is the same as the intended receiver of the message containing the password,
  39.      * to prevent interception of the password by a malicious third party. Always provide a specific targetOrigin,
  40.      * not *, if you know where the other window's document should be located. Failing to provide a specific
  41.      * target discloses the data you send to any interested malicious site.
  42.      * @param message
  43.      */
  44.     public native static void sendMessage(String message) /*-{
  45.         $wnd.parent.postMessage(message, "*");
  46.     }-*/;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement