KickJava   Java API By Example, From Geeks To Geeks.

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


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.ApplicationServletBase;
27 import com.iplanet.jato.RequestContext;
28 import com.iplanet.jato.RequestManager;
29 import com.iplanet.jato.model.DefaultModel;
30 import com.iplanet.jato.model.Model;
31 import com.iplanet.jato.view.ContainerView;
32 import com.iplanet.jato.view.View;
33 import com.iplanet.jato.view.ViewBean;
34
35 import com.sun.enterprise.tools.guiframework.view.descriptors.ViewDescriptor;
36
37 import com.sun.web.ui.view.wizard.CCWizardPage;
38
39 import javax.servlet.http.HttpServletRequest JavaDoc;
40
41
42 public class DescriptorCCWizardPage extends DescriptorRequestHandlingViewBase implements CCWizardPage {
43
44     /**
45      * <P>This class does not get created in the usual way. This constructor
46      * accomodates the way the lockhart wizard does its work. It only accepts
47      * the container and model... however, the model name can be used to get
48      * the ViewDescriptor and we'll get the RequestContext statically.</P>
49      *
50      * <P>NOTE: The model passed in must be assignable to DefaultModel.</P>
51      */

52     public DescriptorCCWizardPage(View view, Model model) {
53     this(
54         RequestManager.getRequestContext(),
55         (ContainerView)view,
56         ((DefaultModel)model).getName(),
57         ViewDescriptorManager.getInstance().getViewDescriptor(RequestManager.getRequestContext().getRequest().getAttribute(VIEW_DESCRIPTOR_NAME).toString()),
58         model);
59     }
60
61
62     /**
63      * This method overrides JATO's getParentViewBean(). This class will be
64      * used as a Pagelet that doesn't know what its parent is. This method
65      * finds the top via the request using PathInfo.
66      */

67     public ViewBean getParentViewBean() {
68     // Try to get the page name
69
RequestContext rc = RequestManager.getRequestContext();
70     HttpServletRequest JavaDoc request = rc.getRequest();
71     String JavaDoc pageName = request.getParameter(ApplicationServletBase.PARAM_HANDLER_BEAN);
72     if (pageName == null) {
73         pageName = request.getPathInfo();
74     }
75     if (pageName != null) {
76         pageName = pageName.trim();
77         while (pageName.charAt(0) == '/') {
78         pageName = pageName.substring(1);
79         }
80         try {
81         return rc.getViewBeanManager().getViewBean(pageName);
82         } catch (ClassNotFoundException JavaDoc ex) {
83         // Ignore...
84
}
85     }
86     return null;
87     }
88
89
90     /**
91      * Constructor
92      */

93     public DescriptorCCWizardPage(RequestContext ctx, ContainerView container, String JavaDoc name, ViewDescriptor desc) {
94     this(ctx, container, name, desc, null);
95     }
96
97
98     /**
99      * Constructor
100      */

101     public DescriptorCCWizardPage(RequestContext ctx, ContainerView container, String JavaDoc name, ViewDescriptor desc, Model model) {
102     super(ctx, container, name, desc, model);
103     }
104
105
106
107     ////////////////////////////////////////////////////////////
108
// CCWizardPage Method //
109
////////////////////////////////////////////////////////////
110

111     /**
112      *
113      * Get the pagelet to use for the rendering of this instance.
114      *
115      * @return The pagelet to use for the rendering of this instance.
116      */

117     public String JavaDoc getPageletUrl() {
118     return getViewDescriptor().getDisplayURL();
119     }
120
121
122     /**
123      * A ServletRequest attribute VIEW_DESCRIPTOR_NAME, should be set to the
124      * ViewDescriptor name that should be instantiated when using the 2 arg
125      * constructor.
126      */

127     public static final String JavaDoc VIEW_DESCRIPTOR_NAME = "_VD_NAME";
128
129     /**
130      * ModelManager name for the Wizard Model
131      */

132     public static final String JavaDoc WIZARD_MODEL = "_wizModel";
133 }
134
Popular Tags