01: /* BaseCheckbox.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Aug 8, 2007 5:48:27 PM 2007, Created by Dennis.Chen
10: }}IS_NOTE
11:
12: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.jsf.zul.impl;
20:
21: import java.util.Map;
22:
23: import javax.faces.context.FacesContext;
24:
25: /**
26: * The Base implementation of Checkbox.
27: * This component should be declared nested under {@link org.zkoss.jsf.zul.Page}.
28: * @author Dennis.Chen
29: *
30: */
31: abstract public class BaseCheckbox extends BranchInput {
32:
33: /**
34: * Override Method, Return ZUL Component attribute name which can handler the submitting of input.
35: * Always return "checked"
36: * @see ClientInputSupport
37: */
38: public String getMappedAttributeName() {
39: return "checked";
40: }
41:
42: /**
43: * Override Method, Decode value in request's parameter.
44: * call by {@link #decode(FacesContext)}
45: */
46: protected void clientInputDecode(FacesContext context) {
47: String clientId = this .getClientId(context);
48: Map requestMap = context.getExternalContext()
49: .getRequestParameterMap();
50: if (requestMap.containsKey(clientId)) {
51: String newValue = (String) context.getExternalContext()
52: .getRequestParameterMap().get(clientId);
53: if ("on".equals(newValue)) {
54: setSubmittedValue("true");
55: return;
56: }
57: }
58: setSubmittedValue("false");
59: }
60:
61: }
|