Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

FeatureServerEvents.java 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* *************************************************************************
  2. IT Mill Toolkit
  3. Development of Browser User Intarfaces Made Easy
  4. Copyright (C) 2000-2006 IT Mill Ltd
  5. *************************************************************************
  6. This product is distributed under commercial license that can be found
  7. from the product package on license/license.txt. Use of this product might
  8. require purchasing a commercial license from IT Mill Ltd. For guidelines
  9. on usage, see license/licensing-guidelines.html
  10. *************************************************************************
  11. For more information, contact:
  12. IT Mill Ltd phone: +358 2 4802 7180
  13. Ruukinkatu 2-4 fax: +358 2 4802 7181
  14. 20540, Turku email: info@itmill.com
  15. Finland company www: www.itmill.com
  16. Primary source for information and releases: www.itmill.com
  17. ********************************************************************** */
  18. package com.itmill.toolkit.demo.features;
  19. import java.net.MalformedURLException;
  20. import java.net.URL;
  21. import com.itmill.toolkit.terminal.ExternalResource;
  22. import com.itmill.toolkit.ui.*;
  23. public class FeatureServerEvents extends Feature {
  24. protected String getTitle() {
  25. return "Server Events";
  26. }
  27. protected Component getDemoComponent() {
  28. OrderedLayout l = new OrderedLayout();
  29. l.addComponent(
  30. new Label(
  31. "<h3>Multiplayer GO-Game</h3><p>For demonstration, see GO-Game example application. The application implements a "
  32. + "multi-player board game, where the moved by one player are immediately reflected to "
  33. + "another player.</p>"
  34. + "<p>Updating another players screen is totally automatic, and the programmed "
  35. + "does not need to be avare when the refresh requests are sent to screen by the server. In "
  36. + "web adapter the requests are passed through open HTTP-connection as java-script fragments "
  37. + "that update the windows that need repainting.</p>",
  38. Label.CONTENT_UIDL));
  39. URL goUrl = null;
  40. try {
  41. goUrl = new URL(getApplication().getURL(), "../go/");
  42. } catch (MalformedURLException e) {
  43. }
  44. if (goUrl != null) {
  45. Link link = new Link("Start GO-Game", new ExternalResource(goUrl));
  46. link.setTargetName("gogame");
  47. link.setTargetBorder(Link.TARGET_BORDER_NONE);
  48. l.addComponent(link);
  49. }
  50. l.addComponent(
  51. new Label(
  52. "<h3>Chat example</h3><p>For some purposes it might be better to create your own "+
  53. "stream. The easiest way of creating a continuous stream for "+
  54. "simple purposes is to use StreamResource-class. See chat "+
  55. "example below, how this technique can be used for creation "+
  56. "of simple chat program.</p>",
  57. Label.CONTENT_UIDL));
  58. URL chatUrl = null;
  59. try {
  60. chatUrl = new URL(getApplication().getURL(), "../chat/");
  61. } catch (MalformedURLException e) {
  62. }
  63. if (goUrl != null) {
  64. Link link = new Link("Start chat", new ExternalResource(chatUrl));
  65. link.setTargetName("chat");
  66. link.setTargetBorder(Link.TARGET_BORDER_NONE);
  67. l.addComponent(link);
  68. }
  69. return l;
  70. }
  71. protected String getDescriptionXHTML() {
  72. return "<p>Millstone component framework supports both transactional and "
  73. + "continuous terminals. This means that either the events from the "
  74. + "terminal are sent together as transactions or the events are "
  75. + "passed immediately when the user initiates them through the user "
  76. + "interface. </p>"
  77. + "<p>WebAdapter converts the Millstone applications to web-environment "
  78. + "by transferring the events as HTTP-parameters and drawing the "
  79. + "pages after the components have received and handled the events. "
  80. + "In the web-environment the web browser is always the active party that "
  81. + "starts the transaction. This is problematic when the server should "
  82. + "notify the user about changes without HTTP-request initiated by the "
  83. + "user.</p>"
  84. + "<h3>WebAdapter Solution</h3>"
  85. + "<p>Millstone solves the problem by combining component frameworks "
  86. + "ability to automatically notify terminal adapter about all visual "
  87. + "changes to HTTP-protocols ability to handle very long and slow "
  88. + "page downloads. WebAdapter provides the web browser with "
  89. + "possibility to keep special server command stream open all the time. "
  90. + "All the visual updates that happen in components causes the "
  91. + "WebAdapter to automatically creates JavaScript that updates the "
  92. + "corresponding web browser window and to send the script immediately "
  93. + "to browser for execution.</p>"
  94. + "<p>The mechanism is fairly complicated, but using the mechanism in "
  95. + "any Millstone application is trivial. Application just needs "
  96. + "to make sure that WebBrowser opens a hidden iframe to location: "
  97. + "<code>?SERVER_COMMANDS=1</code>.</p>"
  98. + "<p>See the example of the usage on Demo-tab to get better understanding "
  99. + "of the mechanism. If you read the example's source code, you will notice that "
  100. + "the program does not contain any support for sending events to client, as "
  101. + "it is completely automatic.</p>";
  102. }
  103. protected String getImage() {
  104. return "serverevents.jpg";
  105. }
  106. }