KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > module > sitemesh > mapper > FrameSetDecoratorMapper


1 /*
2  * Title: FrameSetDecoratorMapper
3  * Description:
4  *
5  * This software is published under the terms of the OpenSymphony Software
6  * License version 1.1, of which a copy has been included with this
7  * distribution in the LICENSE.txt file.
8  */

9
10 package com.opensymphony.module.sitemesh.mapper;
11
12 import com.opensymphony.module.sitemesh.Config;
13 import com.opensymphony.module.sitemesh.Decorator;
14 import com.opensymphony.module.sitemesh.DecoratorMapper;
15 import com.opensymphony.module.sitemesh.HTMLPage;
16 import com.opensymphony.module.sitemesh.Page;
17
18 import javax.servlet.http.HttpServletRequest JavaDoc;
19 import java.util.Properties JavaDoc;
20
21 /**
22  * The FrameSetDecoratorMapper will use the specified decorator when the Page
23  * is an instance of {@link com.opensymphony.module.sitemesh.HTMLPage} and
24  * <code>isFrameSet()</code> returns true.
25  *
26  * <p>The name of this decorator should be supplied in the <code>decorator</code>
27  * property - if no decorator property is supplied, no decorator is applied to
28  * frame based pages.
29  *
30  * @author <a HREF="mailto:joe@truemesh.com">Joe Walnes</a>
31  * @version $Revision: 1.1 $
32  *
33  * @see com.opensymphony.module.sitemesh.DecoratorMapper
34  */

35 public final class FrameSetDecoratorMapper extends AbstractDecoratorMapper {
36     private String JavaDoc decorator = null;
37
38     public void init(Config config, Properties JavaDoc properties, DecoratorMapper parent) throws InstantiationException JavaDoc {
39         super.init(config, properties, parent);
40         decorator = properties.getProperty("decorator");
41     }
42
43     public Decorator getDecorator(HttpServletRequest JavaDoc request, Page page) {
44         if (page instanceof HTMLPage && ((HTMLPage)page).isFrameSet()) {
45             return getNamedDecorator(request, decorator);
46         }
47         else {
48             return super.getDecorator(request, page);
49         }
50     }
51 }
52
Popular Tags