Changeset 5528
- Timestamp:
- 09/26/08 14:04:26 (3 months ago)
- Location:
- trunk/src/com/itmill/toolkit
- Files:
-
- 1 added
- 3 modified
-
Application.java (modified) (3 diffs)
-
terminal/gwt/client/ApplicationConnection.java (modified) (2 diffs)
-
terminal/gwt/server/CommunicationManager.java (modified) (3 diffs)
-
tests/tickets/Ticket2106.java (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/itmill/toolkit/Application.java
r5507 r5528 1394 1394 /** 1395 1395 * Enables or disables the notification. If disabled, the set URL (or 1396 * current) is loaded directly. 1396 * current) is loaded directly when next transaction between server and 1397 * client happens. 1397 1398 * 1398 1399 * @param sessionExpiredNotificationEnabled 1399 * true = enabled, false = disabled1400 * true = enabled, false = disabled 1400 1401 */ 1401 1402 public void setSessionExpiredNotificationEnabled( … … 1406 1407 /** 1407 1408 * Sets the caption of the notification. Set to null for no caption. If 1408 * both caption and message is null, the notification is disabled; 1409 * both caption and message are null, client automatically forwards to 1410 * sessionExpiredUrl after timeout timer expires. Timer uses value read 1411 * from HTTPSession.getMaxInactiveInterval() 1409 1412 * 1410 1413 * @param sessionExpiredCaption … … 1417 1420 /** 1418 1421 * Sets the message of the notification. Set to null for no message. If 1419 * both caption and message is null, the notification is disabled; 1422 * both caption and message are null, client automatically forwards to 1423 * sessionExpiredUrl after timeout timer expires. Timer uses value read 1424 * from HTTPSession.getMaxInactiveInterval() 1420 1425 * 1421 1426 * @param sessionExpiredMessage 1422 * the message1427 * the message 1423 1428 */ 1424 1429 public void setSessionExpiredMessage(String sessionExpiredMessage) { -
trunk/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
r5479 r5528 109 109 /** List of pending variable change bursts that must be submitted in order */ 110 110 private final Vector pendingVariableBursts = new Vector(); 111 112 /** Timer for automatic refirect to SessionExpiredURL */ 113 private Timer redirectTimer; 114 115 /** redirectTimer scheduling interval in seconds */ 116 private int sessionExpirationInterval; 111 117 112 118 public ApplicationConnection(WidgetSet widgetSet, … … 501 507 paintableToId.clear(); 502 508 } 503 } 504 509 if (meta.containsKey("timedRedirect")) { 510 final JSONObject timedRedirect = meta.get("timedRedirect").isObject(); 511 redirectTimer = new Timer() { 512 public void run() { 513 redirect(timedRedirect.get("url").isString().stringValue()); 514 } 515 }; 516 sessionExpirationInterval = Integer.parseInt(timedRedirect.get("interval").toString()); 517 } 518 } 519 if (redirectTimer != null) { 520 redirectTimer.schedule(1000 * sessionExpirationInterval); 521 } 505 522 // Process changes 506 523 final JSONArray changes = (JSONArray) ((JSONObject) json) -
trunk/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java
r5493 r5528 13 13 import java.io.OutputStreamWriter; 14 14 import java.io.PrintWriter; 15 import java.lang.reflect.InvocationTargetException; 15 16 import java.lang.reflect.Method; 16 17 import java.text.DateFormatSymbols; … … 104 105 105 106 private int pendingLocalesIndex; 107 108 private int timeoutInterval = -1; 106 109 107 110 public CommunicationManager(Application application, … … 439 442 metaOpen = true; 440 443 outWriter.write("\"repaintAll\":true"); 444 } 445 446 SystemMessages ci = null; 447 try { 448 Method m = application.getClass().getMethod( 449 "getSystemMessages", null); 450 ci = (Application.SystemMessages) m.invoke(null, null); 451 } catch (NoSuchMethodException e1) { 452 e1.printStackTrace(); 453 } catch (IllegalArgumentException e) { 454 e.printStackTrace(); 455 } catch (IllegalAccessException e) { 456 e.printStackTrace(); 457 } catch (InvocationTargetException e) { 458 e.printStackTrace(); 459 } 460 461 // meta instruction for client to enable auto-forward to 462 // sessionExpiredURL after timer expires. 463 if (ci != null && ci.getSessionExpiredMessage() == null 464 && ci.getSessionExpiredCaption() == null 465 && ci.isSessionExpiredNotificationEnabled()) { 466 int newTimeoutInterval = request.getSession() 467 .getMaxInactiveInterval(); 468 if (repaintAll || (timeoutInterval != newTimeoutInterval)) { 469 String escapedURL = ci.getSessionExpiredURL() == null ? "" 470 : ci.getSessionExpiredURL().replace("/", "\\/"); 471 if (metaOpen) { 472 outWriter.write(","); 473 } 474 outWriter.write("\"timedRedirect\":{\"interval\":" 475 + (newTimeoutInterval + 15) + ",\"url\":\"" 476 + escapedURL + "\"}"); 477 metaOpen = true; 478 } 479 timeoutInterval = newTimeoutInterval; 441 480 } 442 481
