import java.io.PrintWriter;
import java.io.Writer;
import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import org.xml.sax.SAXException;
import com.itmill.toolkit.Application;
+import com.itmill.toolkit.Application.SystemMessages;
import com.itmill.toolkit.external.org.apache.commons.fileupload.servlet.ServletFileUpload;
import com.itmill.toolkit.service.FileTypeResolver;
import com.itmill.toolkit.terminal.DownloadStream;
} catch (final SessionExpired e) {
// Session has expired, notify user
- Application.SystemMessages ci = Application.getSystemMessages();
- try {
- Method m = applicationClass
- .getMethod("getSystemMessages", null);
- ci = (Application.SystemMessages) m.invoke(null, null);
- } catch (Exception e2) {
- // Not critical, but something is still wrong; print stacktrace
- e2.printStackTrace();
- }
-
+ Application.SystemMessages ci = getSystemMessages();
if (!UIDLrequest) {
// 'plain' http req - e.g. browser reload;
// just go ahead redirect the browser
e.printStackTrace();
// if this was an UIDL request, response UIDL back to client
if (UIDLrequest) {
- Application.SystemMessages ci = Application.getSystemMessages();
- try {
- Method m = applicationClass.getMethod("getSystemMessages",
- null);
- ci = (Application.SystemMessages) m.invoke(null, null);
- } catch (Exception e2) {
- // Not critical, but something is still wrong; print
- // stacktrace
- e2.printStackTrace();
- }
+ Application.SystemMessages ci = getSystemMessages();
criticalNotification(request, response, ci
.getInternalErrorCaption(), ci
.getInternalErrorMessage(), ci.getInternalErrorURL());
}
}
+ /** Get system messages from the current application class */
+ private SystemMessages getSystemMessages() {
+ try {
+ Class appCls = applicationClass;
+ if (isApplicationRunnerServlet) {
+ appCls = getClass().getClassLoader().loadClass(
+ applicationRunnerClassname);
+ }
+ Method m = appCls.getMethod("getSystemMessages", null);
+ return (Application.SystemMessages) m.invoke(null, null);
+ } catch (ClassNotFoundException e) {
+ // This should never happen
+ e.printStackTrace();
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ System.out
+ .print("Error: getSystemMessage() should be static public");
+ } catch (NoSuchMethodException e) {
+ // This is completely ok and should be silently ignored
+ } catch (IllegalArgumentException e) {
+ // This should never happen
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ System.out
+ .print("Error: getSystemMessage() should be static public");
+ } catch (InvocationTargetException e) {
+ // This should never happen
+ e.printStackTrace();
+ }
+ return Application.getSystemMessages();
+ }
+
/**
* Serve resources in ITMILL directory if requested.
*
--- /dev/null
+package com.itmill.toolkit.tests.tickets;\r
+\r
+import com.itmill.toolkit.Application;\r
+import com.itmill.toolkit.ui.Button;\r
+import com.itmill.toolkit.ui.Window;\r
+\r
+public class Ticket1673 extends com.itmill.toolkit.Application {\r
+\r
+ public void init() {\r
+\r
+ final Window main = new Window("#1673");\r
+ setMainWindow(main);\r
+\r
+ main.addComponent(new Button("close", this, "close"));\r
+\r
+ }\r
+\r
+ public static Application.SystemMessages getSystemMessages() {\r
+ Application.CustomizedSystemMessages msgs = new Application.CustomizedSystemMessages();\r
+\r
+ msgs.setSessionExpiredURL("http://www.itmill.com/");\r
+ msgs.setSessionExpiredCaption("Foo");\r
+ msgs.setSessionExpiredMessage("Bar");\r
+\r
+ return msgs;\r
+ }\r
+}\r