01: /*
02: *
03: * (c) Copyright 2004 - 2007 osbl development team.
04: *
05: * This file is part of con:cern (http://concern.sf.net).
06: *
07: * the osbl is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU General Public License
09: * as published by the Free Software Foundation; either version 2.1
10: * of the License, or (at your option) any later version.
11: *
12: * Please see COPYING for the complete licence.
13: */
14: package org.osbl.client.wings.shell;
15:
16: import org.wings.session.SessionManager;
17: import org.wings.STemplateLayout;
18:
19: import java.io.File;
20: import java.io.IOException;
21: import java.net.MalformedURLException;
22: import java.net.URL;
23:
24: /**
25: * @version $Revision: 1.2 $
26: */
27: public class Templates {
28: public static URL load(String templateName) {
29: try {
30: String templateDirectory = (String) SessionManager
31: .getSession().getServletContext().getRealPath(
32: "/templates");
33: if (templateDirectory == null)
34: return SessionManager.getSession().getServletContext()
35: .getResource(templateName);
36:
37: templateName = templateDirectory + "/" + templateName;
38:
39: return new File(templateName).toURL();
40: } catch (MalformedURLException e) {
41: throw new RuntimeException(e);
42: }
43: }
44:
45: public static STemplateLayout loadLayout(String path) {
46: try {
47: return new STemplateLayout(load(path));
48: } catch (IOException e) {
49: throw new RuntimeException(e);
50: }
51: }
52: }
|