KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > admingui > view > DescriptorCCHelp2MastheadViewBean


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.admingui.view;
25
26 import com.iplanet.jato.RequestContext;
27 import com.iplanet.jato.NavigationException;
28 import com.iplanet.jato.model.ModelControlException;
29 import com.iplanet.jato.command.Command;
30 import com.iplanet.jato.command.CommandEvent;
31 import com.iplanet.jato.command.CommandException;
32 import com.iplanet.jato.view.View;
33 import com.iplanet.jato.view.event.ChildContentDisplayEvent;
34 import com.iplanet.jato.view.event.ChildDisplayEvent;
35 import com.iplanet.jato.view.event.DisplayEvent;
36
37 import com.sun.enterprise.tools.guiframework.exception.ChildNotRegisteredException;
38 import com.sun.enterprise.tools.guiframework.exception.FrameworkException;
39 import com.sun.enterprise.tools.guiframework.view.descriptors.ViewDescriptor;
40 import com.sun.enterprise.tools.guiframework.view.DescriptorContainerView;
41 import com.sun.enterprise.tools.guiframework.view.DescriptorViewHelper;
42
43 import com.sun.web.ui.servlet.help2.MastheadViewBean;
44
45
46 /**
47  *
48  */

49 public class DescriptorCCHelp2MastheadViewBean extends MastheadViewBean implements DescriptorContainerView, Command {
50
51     /**
52      * Constructor
53      *
54      * @param ctx The RequestContext
55      * @param name The name of the ViewBean
56      * @param desc The ViewDescriptor
57      */

58     public DescriptorCCHelp2MastheadViewBean(RequestContext ctx, String JavaDoc name, ViewDescriptor desc) {
59     super();
60     setRequestContext(ctx);
61     setName(name);
62     setViewDescriptor(desc);
63     registerViewDescriptorChildren();
64     }
65
66
67
68     //////////////////////////////////////////////////////////////////////
69
// Command Methods //
70
//////////////////////////////////////////////////////////////////////
71

72     /**
73      * This method is invoked to dispatch all requests to the appropriate
74      * place.
75      *
76      * @param event The command event, contains information pertinent to
77      * to the invocation of this command
78      *
79      * @throws CommandException Thrown if an error occurs executing
80      * the command
81      */

82     public void execute(CommandEvent event) throws CommandException {
83     DescriptorViewHelper.execute(
84         getRequestContext(), (View)event.getSource(), event);
85     }
86
87
88
89     ////////////////////////////////////////////////////////////
90
// DescriptorContainerView Methods //
91
////////////////////////////////////////////////////////////
92

93     /**
94      * This method sets the ViewDescriptor for this View.
95      */

96     protected void setViewDescriptor(ViewDescriptor desc) {
97     _viewDesc = desc;
98     }
99
100
101     /**
102      * This method retrieves this View ViewDescriptor.
103      *
104      * @return This View's ViewDescriptor.
105      */

106     public ViewDescriptor getViewDescriptor() {
107     return _viewDesc;
108     }
109
110
111     public View createChild(String JavaDoc name) {
112     View child = null;
113     try {
114         // Try to create the Child via a child descriptor
115
child = DescriptorViewHelper.createChild(this, name);
116     } catch (ChildNotRegisteredException ex) {
117         // Some children have built-in support via the super class
118
child = super.createChild(name);
119     }
120
121     // return the child
122
return child;
123     }
124
125
126     /**
127      * Make forwarding easy
128      */

129     public void forwardTo(RequestContext requestContext) throws NavigationException {
130     super.forwardTo(requestContext);
131     }
132
133
134
135     //////////////////////////////////////////////////////////////////////
136
// Event Methods //
137
//////////////////////////////////////////////////////////////////////
138

139     /**
140      * This method dispatches BeginDisplay events to each registered
141      * BeginDisplay event handler according the the ViewDescriptor.
142      * This method is defined in ContainerView, but it is important to
143      * to override this.
144      *
145      * @param event The DisplayEvent, created internally by JATO
146      */

147     public void beginDisplay(DisplayEvent event) throws ModelControlException {
148     DescriptorViewHelper.beginDisplay(this, event);
149     super.beginDisplay(event);
150     }
151
152
153     /**
154      * This method is defined in ContainerView, but it is important to
155      * override this.
156      */

157     public boolean beginChildDisplay(ChildDisplayEvent event) {
158     try {
159         return DescriptorViewHelper.beginChildDisplay(this, event);
160     } catch (Exception JavaDoc ex) {
161         throw new FrameworkException(ex, getViewDescriptor(), this);
162     }
163     }
164
165
166     /**
167      * This method is defined in ContainerView, but it is important to
168      * override this.
169      */

170     public String JavaDoc endChildDisplay(ChildContentDisplayEvent event) throws ModelControlException {
171     return DescriptorViewHelper.endChildDisplay(this, event);
172     }
173
174
175     /**
176      * This method is defined in ContainerView, but it is important to
177      * override this.
178      */

179     public void endDisplay(DisplayEvent event) {
180     DescriptorViewHelper.endDisplay(this, event);
181     super.endDisplay(event);
182     }
183
184
185     /**
186      * <P>Children need to be registered so that values can be submitted back
187      * to DisplayFields, CommandFields can be handled, and containers which
188      * contain these things will work. So... to ensure that
189      * DescriptorContainerView's work, the following
190      * registerViewDescriptorChildren() method must be implemented. This
191      * method is named this way to avoid accidentally overriding a
192      * registerChildren method. Since JATO did not make this part of an
193      * interface, we cannot do super.registerChildren(). <B>This method should
194      * be invoked from the constructor after the ViewDescriptor has been
195      * set.</B> Most implementations of this method should do the
196      * following:</P>
197      *
198      * <BLOCKQUOTE><CODE>
199      * DescriptorViewHelper.registerViewDescriptorChildren(getViewDescriptor(), this);
200      * </CODE></BLOCKQUOTE>
201      *
202      */

203     public void registerViewDescriptorChildren() {
204     DescriptorViewHelper.registerViewDescriptorChildren(getViewDescriptor(), this);
205     }
206
207
208     private ViewDescriptor _viewDesc = null;
209 }
210
Popular Tags