1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
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
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 }