01: /*
02: * This file is part of the WfMOpen project.
03: * Copyright (C) 2001-2006 Danet GmbH (www.danet.de), BU BTS.
04: * All rights reserved.
05: *
06: * This program is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU General Public License as published by
08: * the Free Software Foundation; either version 2 of the License, or
09: * (at your option) any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: *
20: * $Id: JSLoading.java,v 1.2 2006/12/12 09:58:39 drmlipp Exp $
21: *
22: * $Log: JSLoading.java,v $
23: * Revision 1.2 2006/12/12 09:58:39 drmlipp
24: * Added resources and minor cleanup.
25: *
26: * Revision 1.1.2.4 2006/11/28 16:44:31 drmlipp
27: * Started JS based rendering.
28: *
29: * Revision 1.1.2.3 2006/11/27 14:28:33 drmlipp
30: * Continuing.
31: *
32: * Revision 1.1.2.2 2006/11/07 16:33:01 drmlipp
33: * Continuing...
34: *
35: * Revision 1.1.2.1 2006/11/06 16:51:09 drmlipp
36: * Separated JSF taglib from util jar and XForm taglib from util taglib.
37: *
38: */
39: package de.danet.an.util.jsf.taglib;
40:
41: import javax.faces.context.FacesContext;
42:
43: import org.apache.myfaces.renderkit.html.util.AddResource;
44: import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
45:
46: /**
47: * This class provides support for loading the various JavaScript
48: * fragments.
49: *
50: * @author Michael Lipp
51: *
52: */
53: public class JSLoading {
54:
55: public static final String ANCHOR_POSITION = "AnchorPosition.js";
56: public static final String CALENDAR_POPUP = "CalendarPopup.js";
57: public static final String DATE = "date.js";
58: public static final String POPUP_WINDOW = "PopupWindow.js";
59: public static final String UTIL = "util.js";
60: public static final String XMLSAX = "xmlsax.js";
61: public static final String XMLW3CDOM = "xmlw3cdom.js";
62: public static final String XML2HTML = "xml2html.js";
63:
64: /**
65: * Ensure that the specified script is included in the current page.
66: * @param context the faces context
67: * @param script the script to include
68: */
69: public static void ensureInclusion(FacesContext context,
70: String script) {
71: if (!context.getExternalContext().getRequestMap().containsKey(
72: JSLoading.class.getName() + "." + script)) {
73: AddResource addResource = AddResourceFactory
74: .getInstance(context);
75: addResource
76: .addJavaScriptAtPosition(context,
77: AddResource.HEADER_BEGIN,
78: new MyFacesResourceHandler(JSLoading.class,
79: script));
80: context.getExternalContext().getRequestMap().put(
81: JSLoading.class.getName() + "." + script,
82: Boolean.TRUE);
83: }
84: }
85:
86: }
|