Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Entry point classes define <code>onModuleLoad()</code>.
- */
- public class Testdialog2 implements EntryPoint {
- /**
- * This is the entry point method.
- */
- public void onModuleLoad() {
- final TextBox nameField = new TextBox();
- final Button sendButton = new Button("Send");
- sendButton.addStyleName("sendButton");
- sendButton.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- sendMessage(nameField.getValue());
- }
- });
- nameField.setText("Message To Send Via postMessage");
- RootPanel.get().add(sendButton);
- RootPanel.get().add(nameField);
- nameField.setFocus(true);
- nameField.selectAll();
- }
- /**
- * Specifies what the origin of otherWindow must be for the event to be dispatched, either as the literal string "*"
- * (indicating no * preference) or as a URI. If at the time the event is scheduled to be dispatched the scheme,
- * hostname, or port of otherWindow's document does not match that provided in targetOrigin, the event will not be dispatched;
- * only if all three match will the event be dispatched. This mechanism provides control over where messages are sent;
- * for example, if postMessage was used to transmit a password, it would be absolutely critical that this
- * argument be a URI whose origin is the same as the intended receiver of the message containing the password,
- * to prevent interception of the password by a malicious third party. Always provide a specific targetOrigin,
- * not *, if you know where the other window's document should be located. Failing to provide a specific
- * target discloses the data you send to any interested malicious site.
- * @param message
- */
- public native static void sendMessage(String message) /*-{
- $wnd.parent.postMessage(message, "*");
- }-*/;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement