View Javadoc

1   // 
2   // Copyright (c) 2003, Caltha - Gajda, Krzewski, Mach, Potempski Sp.J. 
3   // All rights reserved. 
4   // 
5   // Redistribution and use in source and binary forms, with or without modification,  
6   // are permitted provided that the following conditions are met: 
7   //  
8   // * Redistributions of source code must retain the above copyright notice,  
9   //	 this list of conditions and the following disclaimer. 
10  // * Redistributions in binary form must reproduce the above copyright notice,  
11  //	 this list of conditions and the following disclaimer in the documentation  
12  //	 and/or other materials provided with the distribution. 
13  // * Neither the name of the Caltha - Gajda, Krzewski, Mach, Potempski Sp.J.  
14  //	 nor the names of its contributors may be used to endorse or promote products  
15  //	 derived from this software without specific prior written permission. 
16  // 
17  // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"  
18  // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED  
19  // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
20  // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,  
21  // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,  
22  // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
23  // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  
24  // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)  
25  // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE  
26  // POSSIBILITY OF SUCH DAMAGE. 
27  // 
28  package org.objectledge.web.mvc.finders;
29  
30  import org.objectledge.templating.Template;
31  
32  /***
33   * Finds templates that should be used for rendering specific views and web page components.
34   *
35   * @author <a href="mailto:dgajda@caltha.pl">Damian Gajda</a>
36   * @version $Id: MVCTemplateFinder.java,v 1.14 2005/07/22 17:25:53 pablo Exp $
37   */
38  public interface MVCTemplateFinder
39  {
40      // builders /////////////////////////////////////////////////////////////////////////////////
41      
42  	/***
43  	 * Returns a result object containing reference to the found builder template for a given view
44       * name. If no template is found, a <code>null</code> template is returned in the result object.
45       * The <b>find</b>ing of the view tamplates uses the defaulting strategy based on
46       * the {@link ViewFallbackSequence} name sequence generation.
47  	 * 
48       * @param name view name to look up template for.
49  	 * @return found template with accompanying info.
50       */
51      public Result findBuilderTemplate(String name);
52  
53  	// components /////////////////////////////////////////////////////////////////////////////////
54      
55  	/***
56  	 * Returns an component template for a given component name. If no template is found, a
57  	 * <code>null</code> is returned.
58  	 * 
59  	 * @param name component name to look up template for.
60  	 * @return found template
61  	 */
62  	public Template getComponentTemplate(String name);
63      
64      /***
65       * The search result for builder template find method.
66       *  
67       * @author <a href="mailto:dgajda@caltha.pl">Damian Gajda</a>
68       */
69      public static class Result
70      {
71          private final String originalView;
72          private final Template template;
73          private final String actualView;
74          
75          /***
76           * Creates a new Result instance.
77           * 
78           * @param originalView originally requested template.
79           * @param template resolved template.
80           * @param actualView the actual view associated with the resolved template.
81           */
82          public Result(String originalView, Template template, String actualView)
83          {
84              this.originalView = originalView;
85              this.template = template;
86              this.actualView = actualView;
87          }
88  
89          /***
90           * @return Returns the original view used to search for the builder template.
91           */
92          public String getOriginalView()
93          {
94              return originalView;
95          }
96  
97          /***
98           * @return Returns the actual view name computed during search.
99           */
100         public String getActualView()
101         {
102             return actualView;
103         }
104 
105         /***
106          * @return Returns the found builder template.
107          */
108         public Template getTemplate()
109         {
110             return template;
111         }
112         
113         /***
114          * @return Tells whether fallback on view name was preformed during builder template search.
115          */
116         public boolean fallbackPerformed()
117         {
118             return !originalView.equals(actualView);
119         }
120     }
121 }