You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

HelloWorldExtensionConnector.java 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright 2011 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.widgetset.client.helloworldfeature;
  17. import com.google.gwt.user.client.Window;
  18. import com.vaadin.client.ServerConnector;
  19. import com.vaadin.client.Util;
  20. import com.vaadin.client.VConsole;
  21. import com.vaadin.client.extensions.AbstractExtensionConnector;
  22. import com.vaadin.shared.ui.Connect;
  23. import com.vaadin.tests.extensions.HelloWorldExtension;
  24. @Connect(HelloWorldExtension.class)
  25. public class HelloWorldExtensionConnector extends AbstractExtensionConnector {
  26. @Override
  27. public HelloWorldState getState() {
  28. return (HelloWorldState) super.getState();
  29. }
  30. @Override
  31. protected void init() {
  32. registerRpc(GreetAgainRpc.class, new GreetAgainRpc() {
  33. @Override
  34. public void greetAgain() {
  35. greet();
  36. }
  37. });
  38. }
  39. @Override
  40. protected void extend(ServerConnector target) {
  41. greet();
  42. }
  43. private void greet() {
  44. String msg = getState().getGreeting() + " from "
  45. + Util.getConnectorString(this) + " attached to "
  46. + Util.getConnectorString(getParent());
  47. VConsole.log(msg);
  48. String response = Window.prompt(msg, "");
  49. getRpcProxy(HelloWorldRpc.class).onMessageSent(response);
  50. }
  51. }