KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > guiframework > view > descriptors > CCCheckBoxDescriptor


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.tools.guiframework.view.descriptors;
25
26 import com.iplanet.jato.RequestContext;
27 import com.iplanet.jato.view.html.CheckBox;
28 import com.iplanet.jato.view.View;
29 import com.iplanet.jato.view.ContainerView;
30 import com.sun.web.ui.view.html.CCCheckBox;
31
32
33 /**
34  *
35  */

36 public class CCCheckBoxDescriptor extends DisplayFieldDescriptor {
37     
38     private final String JavaDoc CHECKED_VALUE = "checkedValue";
39     private final String JavaDoc UNCHECKED_VALUE= "uncheckedValue";
40
41     /**
42      * Constructor
43      */

44     public CCCheckBoxDescriptor(String JavaDoc name) {
45     super(name);
46     }
47
48
49     /**
50      * This is a factory method for CheckBox instances.
51      *
52      * @param ctx The RequestContext
53      * @param container The container for the newly created
54      */

55     public View getInstance(RequestContext ctx, ContainerView container, String JavaDoc name) {
56         // Check to see if a default value was supplied, use "true" if not
57
Object JavaDoc value =
58         getParameter(DisplayFieldDescriptor.DEFAULT_VALUE);
59     boolean initialValue = true;
60     if (value != null) {
61         initialValue = new Boolean JavaDoc(value.toString()).booleanValue();
62     }
63
64 // FIXME: Support models
65
// Create and return the CheckBox, with the values specified.
66
// If the values are not specified use "true" for checked, "false" unchecked.
67
Object JavaDoc checkedValue = getParameter(CHECKED_VALUE);
68     Object JavaDoc uncheckedValue = getParameter(UNCHECKED_VALUE);
69
70     if(checkedValue == null) {
71         checkedValue = "true";
72     }
73     if(uncheckedValue == null) {
74         uncheckedValue="false";
75     }
76     CheckBox checkbox =
77         new CCCheckBox(container, name, checkedValue, uncheckedValue, initialValue);
78     setBoundName(checkbox);
79     return checkbox;
80     }
81 }
82
Popular Tags