KickJava   Java API By Example, From Geeks To Geeks.

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


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.ContainerView;
28 import com.iplanet.jato.view.DisplayField;
29 import com.iplanet.jato.view.View;
30
31 import com.sun.web.ui.model.CCPropertySheetModelInterface;
32 import com.sun.enterprise.tools.guiframework.event.descriptors.EventDescriptor;
33 import com.sun.enterprise.tools.guiframework.event.descriptors.HandlerDescriptor;
34 import com.sun.enterprise.tools.guiframework.event.descriptors.UseHandlerDescriptor;
35 import com.sun.enterprise.tools.guiframework.view.HandlerContext;
36 import com.sun.web.ui.taglib.html.CCTextFieldTag;
37
38
39 /**
40  * This Descriptor is needed so that children of a CCPropertySheet can be
41  * created from the CCPropertySheet's model rather than directly.
42  */

43 public class CCPropertySheetChildDescriptor extends DisplayFieldDescriptor {
44
45     /**
46      * Constructor
47      */

48     public CCPropertySheetChildDescriptor(String JavaDoc name) {
49     super(name);
50         addBeginDisplayHandler(this);
51         //addEndDisplayHandler(this);
52
}
53
54
55     /**
56      * This method returns the model associated with this View (it is actually
57      * obtained from the parent ViewDescriptor).
58      */

59     protected CCPropertySheetModelInterface getModel() {
60     return ((CCPropertySheetDescriptor)getParent()).getModel();
61     }
62
63
64     /**
65      * This is a factory method.
66      *
67      * @param ctx The RequestContext
68      * @param container The container for the newly created
69      */

70     public View getInstance(RequestContext ctx, ContainerView container, String JavaDoc name) {
71     CCPropertySheetModelInterface model = getModel();
72     if (model != null && model.isChildSupported(name)) {
73         View child = model.createChild(container, name);
74         
75         if (child instanceof DisplayField) {
76                 DisplayField field = (DisplayField)child;
77
78         // Set the binding
79
setBoundName(field);
80
81         // possibly set the default value from the view desc.
82
setDefaultValue(child);
83         }
84
85         return child;
86     }
87     return null;
88     }
89     
90     private void addBeginDisplayHandler(ViewDescriptor desc) {
91         EventDescriptor ev = desc.getEventDescriptor(EventDescriptor.TYPES.BEGIN_DISPLAY);
92         if (ev == null) {
93             ev = new EventDescriptor(desc, EventDescriptor.TYPES.BEGIN_DISPLAY);
94         }
95         HandlerDescriptor hd = new HandlerDescriptor("beginFixTextDisplay");
96         hd.setHandlerMethod(
97             "com.sun.enterprise.tools.guiframework.event.handlers.ViewDescriptorHandlers",
98             "beginFixTextDisplay");
99
100         UseHandlerDescriptor useDesc = new UseHandlerDescriptor(ev, hd);
101         ev.addEventHandler(useDesc);
102         desc.setEventDescriptor(ev);
103     }
104
105 // private void addEndDisplayHandler(ViewDescriptor desc) {
106
// EventDescriptor ev = desc.getEventDescriptor("endDisplay");
107
// if (ev == null) {
108
// ev = new EventDescriptor(desc, "endDisplay");
109
// desc.setEventDescriptor(ev);
110
// }
111
// HandlerDescriptor hd = new HandlerDescriptor("endExtendedTextDisplay");
112
// hd.setHandlerMethod(
113
// "com.sun.enterprise.tools.guiframework.event.handlers.ViewDescriptorHandlers",
114
// "endFixTextDisplay");
115
//
116
// UseHandlerDescriptor useDesc = new UseHandlerDescriptor(ev, hd);
117
// ev.addEventHandler(useDesc);
118
// }
119
}
120
Popular Tags