01: package com.opensymphony.webwork.components;
02:
03: import com.opensymphony.xwork.util.OgnlValueStack;
04:
05: import javax.servlet.http.HttpServletRequest;
06: import javax.servlet.http.HttpServletResponse;
07:
08: /**
09: * <!-- START SNIPPET: javadoc -->
10: *
11: * Creates a series of checkboxes from a list. Setup is like <ww:select /> or <ww:radio />, but creates checkbox tags.
12: *
13: * <!-- END SNIPPET: javadoc -->
14: *
15: * <p/> <b>Examples</b>
16: *
17: * <pre>
18: * <!-- START SNIPPET: example -->
19: * <ww:checkboxlist name="foo" list="bar"/>
20: * <!-- END SNIPPET: example -->
21: * </pre>
22: *
23: * <!-- START SNIPPET: example2Description -->
24: * It is possible to select multiple checkboxes, by handling a List into the value attribute.
25: * The List passed into the value attribute could be :-
26: * <ul>
27: * <li>key if the list attribute is passed in is a Map</li>
28: * <li>listKey properties if listKey attribute is used</li>
29: * <li>entry/entries passed into the list attribute</li>
30: * </ul>
31: * <!-- END SNIPPET: example2Description -->
32: *
33: * <pre>
34: * <!-- START SNIPPET: anotherExample -->
35: * <ww:checkboxlist name="options"
36: * list="%{#{'FOO':'foo','BAR':'bar','BAZ':'baz','BOO':'boo'}}"
37: * value="%{{'FOO','BAZ'}}" />
38: *
39: * <ww:checkboxlist name="options"
40: * list="%{{'Foo','Bar','Baz'}}"
41: * value="%{{'Foo','Bar'}}" />
42: *
43: * public class MyAction extends ActionSupport {
44: * public List<Choice> getChoices() {
45: * ....
46: * }
47: * ....
48: * public List<String> getPreSelectedChoices() {
49: * // returns a list of Choice.getKey(), which is a String
50: * ....
51: * }
52: * }
53: *
54: * public class Choice {
55: * public String getKey() { ...}
56: * public String getDisplayName() { ... }
57: * ....
58: * }
59: *
60: * <ww:checkboxlist name="myChoice"
61: * list="%{choices}"
62: * listKey="%{'key'}"
63: * listValue="%{'displayName'}"
64: * value="%{preSelectedChoices}" />
65: *
66: * <!-- END SNIPPET: anotherExample -->
67: * </pre>
68: *
69: * @author Patrick Lightbody
70: * @author Rene Gielen
71: * @version $Revision: 2746 $
72: * @since 2.2
73: *
74: * @ww.tag name="checkboxlist" tld-body-content="JSP" tld-tag-class="com.opensymphony.webwork.views.jsp.ui.CheckboxListTag"
75: * description="Render a list of checkboxes"
76: */
77: public class CheckboxList extends ListUIBean {
78: final public static String TEMPLATE = "checkboxlist";
79:
80: public CheckboxList(OgnlValueStack stack,
81: HttpServletRequest request, HttpServletResponse response) {
82: super (stack, request, response);
83: }
84:
85: protected String getDefaultTemplate() {
86: return TEMPLATE;
87: }
88: }
|