KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > guiframework > view > DescriptorWizardWindowViewBean


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;
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
41 import com.sun.web.ui.model.wizard.WizardInterface;
42 import com.sun.web.ui.servlet.wizard.WizardWindowViewBean;
43
44
45 /**
46  *
47  */

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

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

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

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

91     /**
92      * This method sets the ViewDescriptor for this View.
93      */

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

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

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

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

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

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

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

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

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