KickJava   Java API By Example, From Geeks To Geeks.

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


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.NavigationException;
27 import com.iplanet.jato.RequestContext;
28 import com.iplanet.jato.model.Model;
29 import com.iplanet.jato.model.ModelControlException;
30 import com.iplanet.jato.view.RequestHandlingViewBase;
31 import com.iplanet.jato.view.ContainerView;
32 import com.iplanet.jato.view.View;
33 import com.iplanet.jato.view.event.ChildDisplayEvent;
34 import com.iplanet.jato.view.event.ChildContentDisplayEvent;
35 import com.iplanet.jato.view.event.DisplayEvent;
36
37 import com.sun.enterprise.tools.guiframework.view.descriptors.ViewDescriptor;
38
39
40 public class DescriptorRequestHandlingViewBase extends RequestHandlingViewBase implements DescriptorContainerView {
41
42     /**
43      * Constructor
44      */

45     public DescriptorRequestHandlingViewBase(RequestContext ctx, ContainerView container, String JavaDoc name, ViewDescriptor desc) {
46     this(ctx, container, name, desc, null);
47     }
48
49     /**
50      * Constructor w/ Model. This is important so that the a model can be set
51      * before child registration.
52      */

53     public DescriptorRequestHandlingViewBase(RequestContext ctx, ContainerView container, String JavaDoc name, ViewDescriptor desc, Model model) {
54     super(container, name);
55     setRequestContext(ctx);
56     setViewDescriptor(desc);
57     if (model != null) {
58         setDefaultModel(model);
59     }
60     registerViewDescriptorChildren();
61     }
62
63
64     /**
65      * This method retrieves this View ViewDescriptor.
66      *
67      * @return This View's ViewDescriptor.
68      */

69     public ViewDescriptor getViewDescriptor() {
70     return _viewDesc;
71     }
72
73
74     /**
75      * This method sets the ViewDescriptor for this View.
76      */

77     protected void setViewDescriptor(ViewDescriptor desc) {
78     _viewDesc = desc;
79     }
80
81
82     /**
83      * This method registerd the Descriptor children.
84      */

85     public void registerViewDescriptorChildren() {
86     DescriptorViewHelper.registerViewDescriptorChildren(getViewDescriptor(), this);
87     }
88
89
90     /**
91      * This method is defined in ContainerView, but it is important to
92      * to override this.
93      *
94      * This method should delegate to the helper createChild method to use the
95      * descriptor information
96      */

97     public View createChild(String JavaDoc name) {
98         // Try to create the Child via a child descriptor
99
return DescriptorViewHelper.createChild(this, name);
100     }
101
102
103     /**
104      *
105      */

106     public RequestContext getRequestContext() {
107     return _reqCtx;
108     }
109
110
111     /**
112      *
113      */

114     public void setRequestContext(RequestContext context) {
115     _reqCtx = context;
116     }
117
118
119     public void forwardTo(RequestContext requestContext) throws NavigationException {
120     getParentViewBean().forwardTo(requestContext);
121     }
122
123
124
125     ////////////////////////////////////////////////////////////
126
// Event Methods //
127
////////////////////////////////////////////////////////////
128

129     /**
130      * This method dispatches BeginDisplay events to each registered
131      * BeginDisplay event handler according the the ViewDescriptor.
132      * This method is defined in ContainerView, but it is important to
133      * to override this.
134      *
135      * @param event The DisplayEvent, created internally by JATO
136      */

137     public void beginDisplay(DisplayEvent event) throws ModelControlException {
138     DescriptorViewHelper.beginDisplay(this, event);
139     super.beginDisplay(event);
140     }
141
142
143     public boolean beginChildDisplay(ChildDisplayEvent event) throws ModelControlException {
144         return DescriptorViewHelper.beginChildDisplay(this, event);
145     }
146
147
148     public String JavaDoc endChildDisplay(ChildContentDisplayEvent event) throws ModelControlException {
149     return DescriptorViewHelper.endChildDisplay(this, event);
150     }
151
152
153     public void endDisplay(DisplayEvent event) {
154     DescriptorViewHelper.endDisplay(this, event);
155     super.endDisplay(event);
156     }
157
158
159     private RequestContext _reqCtx = null;
160     private ViewDescriptor _viewDesc = null;
161 }
162
Popular Tags