From e89b20ab51f508cc7e0e773d457733c40958c9d3 Mon Sep 17 00:00:00 2001 From: Jani Laakso Date: Thu, 24 May 2007 12:52:48 +0000 Subject: [PATCH] Providing informative message on how to configure themes on warning and error cases that are theme related. svn changeset:1488/svn branch:trunk --- .../terminal/web/ApplicationServlet.java | 18 +++++++++--------- src/com/itmill/toolkit/terminal/web/Theme.java | 9 ++++++++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/com/itmill/toolkit/terminal/web/ApplicationServlet.java b/src/com/itmill/toolkit/terminal/web/ApplicationServlet.java index 5a0da13f98..9bf94650c3 100644 --- a/src/com/itmill/toolkit/terminal/web/ApplicationServlet.java +++ b/src/com/itmill/toolkit/terminal/web/ApplicationServlet.java @@ -320,14 +320,16 @@ public class ApplicationServlet extends HttpServlet implements // Checks that at least one themesource was loaded if (this.themeSource.getThemes().size() <= 0) { + throw new ServletException( + "No themes found in specified themesources. " + + Theme.MESSAGE_CONFIGURE_HELP); + } + + // Warn if default theme not found + if (this.themeSource.getThemeByName(DEFAULT_THEME) == null) { if (!defaultThemeFound) Log.warn("Default theme JAR not found in: " + Arrays.asList(defaultThemeFiles)); - throw new ServletException( - "No themes found in specified themesources. " - + "You can provide themes by e.g. adding " - + "itmill-toolkit-x.y.z-themes.jar " - + "to WEB-INF/lib directory."); } // Initializes the transformer factory, if not initialized @@ -605,10 +607,8 @@ public class ApplicationServlet extends HttpServlet implements Theme theme = themeSource.getThemeByName(themeName); if (theme == null) throw new ServletException( - "Failed to load theme with name " - + themeName - + ". Check that theme's description.xml " - + "contains correct theme name."); + "Failed to load theme with name " + themeName + + ". " + Theme.MESSAGE_CONFIGURE_HELP); String renderingMode = theme.getPreferredMode(wb, themeSource); diff --git a/src/com/itmill/toolkit/terminal/web/Theme.java b/src/com/itmill/toolkit/terminal/web/Theme.java index 931a85ada3..dbc879e7b4 100644 --- a/src/com/itmill/toolkit/terminal/web/Theme.java +++ b/src/com/itmill/toolkit/terminal/web/Theme.java @@ -138,6 +138,12 @@ public class Theme extends DefaultHandler { public static final String MODE_FALLBACK = MODE_HTML; + public static final String MESSAGE_CONFIGURE_HELP = "You can provide themes by adding " + + "itmill-toolkit-x.y.z-themes.jar " + + "to WEB-INF/lib directory or adding " + + "theme files under WEB-INF/lib/themes directory." + + " Check also theme's description.xml."; + /** * Name of the theme. */ @@ -282,7 +288,8 @@ public class Theme extends DefaultHandler { Theme parent = themeSource.getThemeByName(parentTheme); if (parent == null) throw new IllegalStateException("Parent theme '" + parentTheme - + "' is not found for theme '" + getName() + "'."); + + "' is not found for theme '" + getName() + "'. " + + MESSAGE_CONFIGURE_HELP); if (!parent.supportsMode(mode, terminal, themeSource)) return false; } -- 2.39.5