01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.responders.search;
04:
05: import fitnesse.http.*;
06: import fitnesse.*;
07: import fitnesse.html.*;
08:
09: public class SearchFormResponder implements Responder {
10: public Response makeResponse(FitNesseContext context,
11: Request request) throws Exception {
12: SimpleResponse response = new SimpleResponse();
13: response.setContent(html(context));
14:
15: return response;
16: }
17:
18: private String html(FitNesseContext context) throws Exception {
19: HtmlPage page = context.htmlPageFactory.newPage();
20: page.body.addAttribute("onload",
21: "document.forms[0].searchString.focus()");
22: HtmlUtil.addTitles(page, "Search Form");
23: page.main.use(makeRightColumn());
24: return page.html();
25: }
26:
27: private HtmlTag makeRightColumn() {
28: HtmlTag form = new HtmlTag("form");
29: form.addAttribute("action", "search");
30: form.addAttribute("method", "post");
31: form
32: .add(HtmlUtil.makeInputTag("hidden", "responder",
33: "search"));
34:
35: form.add("Search String:");
36: form.add(HtmlUtil.makeInputTag("text", "searchString", ""));
37: form.add(HtmlUtil.BR);
38: form.add(HtmlUtil.makeInputTag("submit", "searchType",
39: "Search Titles!"));
40: form.add(HtmlUtil.makeInputTag("submit", "searchType",
41: "Search Content!"));
42:
43: form.add(HtmlUtil.BR);
44: form.add(HtmlUtil.BR);
45: form.add(new HtmlTag("b", "Search Titles!: "));
46: form
47: .add("Searches in page titles only. Will run fairly quickly.");
48: form.add(HtmlUtil.BR);
49: form.add(new HtmlTag("b", "Search Content!: "));
50: form
51: .add("Searches in the content of every page. Don't hold your breath.");
52:
53: return form;
54: }
55:
56: }
|