KickJava   Java API By Example, From Geeks To Geeks.

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


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.ContainerView;
31 import com.iplanet.jato.view.View;
32 import com.iplanet.jato.view.event.ChildDisplayEvent;
33 import com.iplanet.jato.view.event.ChildContentDisplayEvent;
34 import com.iplanet.jato.view.event.DisplayEvent;
35
36 import com.sun.enterprise.tools.guiframework.exception.ChildNotRegisteredException;
37 import com.sun.enterprise.tools.guiframework.exception.FrameworkException;
38 import com.sun.enterprise.tools.guiframework.view.descriptors.ViewDescriptor;
39
40 import com.sun.web.ui.model.CCActionTableModel;
41 import com.sun.web.ui.view.table.CCActionTable;
42
43
44 public class DescriptorCCActionTableTiledView extends DescriptorTiledView {
45
46     /**
47      * Constructor
48      */

49     public DescriptorCCActionTableTiledView(RequestContext ctx, ContainerView container, String JavaDoc name, ViewDescriptor desc, Model model) {
50     super(ctx, container, name, desc);
51     setDefaultModel(model); // This will be used for PrimaryModel also
52
}
53
54
55     /**
56      * This method is defined in ContainerView, but it is important to
57      * to override this.
58      *
59      * This method should delegate to the helper createChild method to use the
60      * descriptor information
61      */

62     public View createChild(String JavaDoc name) {
63     View child = null;
64     try {
65         // Try to create the Child via a child descriptor
66
child = DescriptorViewHelper.createChild(this, name);
67     } catch (ChildNotRegisteredException ex) {
68         // Some children have built-in support via CCActionTable
69
View parent = getParent();
70         while ((parent != null) && !(parent instanceof CCActionTable)) {
71         parent = parent.getParent();
72         }
73         if (parent == null) {
74         throw new FrameworkException("Unable to create child '"+name+
75             "'.", ex, getViewDescriptor().getChildDescriptor(name), this);
76         }
77         child = ((ContainerView)parent).getChild(name);
78     }
79
80     // return the child
81
return child;
82     }
83
84
85     ////////////////////////////////////////////////////////////
86
// Event Methods //
87
////////////////////////////////////////////////////////////
88

89     /**
90      *
91      */

92     public boolean beginChildDisplay(ChildDisplayEvent event) throws ModelControlException {
93     if (getViewDescriptor().getChildDescriptor(event.getChildName()) == null) {
94         // This means that an event was called expecting the child to be
95
// under this tiled view, but it is possible that it may be
96
// directly in the parent. This is because fields like href's may
97
// choose to not be indexed, but may appear in the tiled view.
98
return DescriptorViewHelper.beginChildDisplay(
99         ((DescriptorContainerView)getParent()), event);
100     }
101     return DescriptorViewHelper.beginChildDisplay(this, event);
102     }
103
104
105     /**
106      *
107      */

108     public String JavaDoc endChildDisplay(ChildContentDisplayEvent event) throws ModelControlException {
109     if (getViewDescriptor().getChildDescriptor(event.getChildName()) == null) {
110         // This means that an event was called expecting the child to be
111
// under this tiled view, but it is possible that it may be
112
// directly in the parent. This is because fields like href's may
113
// choose to not be indexed, but may appear in the tiled view.
114
return DescriptorViewHelper.endChildDisplay(
115         ((DescriptorContainerView)getParent()), event);
116     }
117     return DescriptorViewHelper.endChildDisplay(this, event);
118     }
119 }
120
Popular Tags