1 |
| package photospace.web.tags; |
2 |
| |
3 |
| import javax.servlet.jsp.*; |
4 |
| import javax.servlet.jsp.tagext.*; |
5 |
| import photospace.*; |
6 |
| import photospace.search.*; |
7 |
| |
8 |
| public class SearchTag |
9 |
| extends TagSupport |
10 |
| { |
11 |
| private String var = "result"; |
12 |
| private int scope = PageContext.PAGE_SCOPE; |
13 |
| private String query; |
14 |
| private int order = Searcher.ASCENDING; |
15 |
| private int start = 0; |
16 |
| private int end = -1; |
17 |
| |
18 |
0
| public int doStartTag() throws JspTagException
|
19 |
| { |
20 |
0
| try
|
21 |
| { |
22 |
0
| pageContext.setAttribute(var, Application.searcher().search(query, order, start, end), scope);
|
23 |
| } |
24 |
| catch (Exception e) |
25 |
| { |
26 |
0
| throw new JspTagException(e);
|
27 |
| } |
28 |
0
| return EVAL_BODY_INCLUDE;
|
29 |
| } |
30 |
| |
31 |
0
| public void setQuery(String query)
|
32 |
| { |
33 |
0
| this.query = query;
|
34 |
| } |
35 |
| |
36 |
0
| public void setOrder(int order)
|
37 |
| { |
38 |
0
| this.order = order;
|
39 |
| } |
40 |
| |
41 |
0
| public void setStart(int start)
|
42 |
| { |
43 |
0
| this.start = start;
|
44 |
| } |
45 |
| |
46 |
0
| public void setEnd(int end)
|
47 |
| { |
48 |
0
| this.end = end;
|
49 |
| } |
50 |
| |
51 |
0
| public void setVar(String var)
|
52 |
| { |
53 |
0
| this.var = var;
|
54 |
| } |
55 |
| |
56 |
0
| public void setScope(String scope)
|
57 |
| { |
58 |
0
| if (PageContext.REQUEST.equalsIgnoreCase(scope))
|
59 |
0
| this.scope = PageContext.REQUEST_SCOPE;
|
60 |
0
| else if (PageContext.SESSION.equalsIgnoreCase(scope))
|
61 |
0
| this.scope = PageContext.SESSION_SCOPE;
|
62 |
0
| else if (PageContext.APPLICATION.equalsIgnoreCase(scope))
|
63 |
0
| this.scope = PageContext.APPLICATION_SCOPE;
|
64 |
| } |
65 |
| } |