1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.tapfx.components.table;
17
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20
21 import org.apache.tapestry.IMarkupWriter;
22 import org.apache.tapestry.IRequestCycle;
23 import org.apache.tapestry.contrib.table.components.Table;
24 import org.apache.tapestry.event.PageDetachListener;
25 import org.apache.tapestry.event.PageEvent;
26 import org.apache.tapestry.form.Form;
27 import org.apache.tapestry.form.TextField;
28 import org.apache.tapestry.html.Body;
29
30 /***
31 * @author andyhot
32 */
33 public abstract class FilteringTable extends Table implements PageDetachListener
34 {
35 private static final Log log = LogFactory.getLog(FilteringTable.class);
36
37 public abstract String getFilter();
38 public abstract void setFilterChanged(boolean value);
39 public abstract boolean isFilterChanged();
40 public abstract boolean getUseFilter();
41
42 protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
43 {
44 if (getUseFilter())
45 {
46 TextField textField = (TextField) this.getComponent("txfFilter");
47 Form form = (Form) this.getComponent("frmFilter");
48
49 if (textField.getName()!=null)
50 {
51
52 String script = "document." + form.getName() + "."
53 + textField.getName() + ".focus();";
54
55 Body body = Body.get(cycle);
56 if (body != null)
57 body.addInitializationScript(script);
58 else
59 log.info("Body is null!");
60 }
61 }
62 super.renderComponent(writer, cycle);
63 }
64
65 public void pageDetached(PageEvent event)
66 {
67
68
69
70 }
71
72 public void onFilterSubmit(IRequestCycle cycle)
73 {
74
75
76 }
77 }