KickJava   Java API By Example, From Geeks To Geeks.

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


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.view.ViewBean;
28 import com.iplanet.jato.view.event.RequestInvocationEvent;
29
30 import com.sun.enterprise.tools.guiframework.exception.FrameworkException;
31 import com.sun.enterprise.tools.guiframework.view.descriptors.ViewDescriptor;
32 import com.sun.enterprise.tools.guiframework.view.descriptors.CCTabsDescriptor;
33
34 import com.sun.web.ui.view.tabs.CCNodeEventHandlerInterface;
35
36 import java.util.Iterator JavaDoc;
37
38
39 public class CCNodeEventHandlerViewBeanBase extends DescriptorViewBeanBase implements CCNodeEventHandlerInterface {
40     /**
41      * Constructor
42      */

43     public CCNodeEventHandlerViewBeanBase(RequestContext context, String JavaDoc pageName, ViewDescriptor desc) {
44     super(context, pageName, desc);
45     }
46
47
48     /**
49      * This method is invoked when the user click on a tab. If the child
50      * CCTabsDescriptor is named "Tabs", then it will be found via a simple
51      * Map lookup. However, if it is not, then the first CCTabsDescriptor
52      * found will be used. This implies that only 1 CCTabsDescriptor may
53      * exist per ViewBean.
54      *
55      * @param event The request invocation event
56      * @param nodeID The selected node id
57      */

58     public void nodeClicked(RequestInvocationEvent event, int nodeID) {
59         // Look for the tab component by name
60
CCTabsDescriptor tabDesc =
61         (CCTabsDescriptor)getViewDescriptor().getChildDescriptor("Tabs");
62
63     // Check to see if we found it...
64
if (tabDesc == null) {
65         // We didn't find it by name... iterate through looking all the
66
// child descriptors, looking for the correct type.
67
Iterator JavaDoc it = getViewDescriptor().getChildDescriptors().iterator();
68         ViewDescriptor desc = null;
69         while (it.hasNext()) {
70         desc = (ViewDescriptor)it.next();
71         if (desc instanceof CCTabsDescriptor) {
72             tabDesc = (CCTabsDescriptor)desc;
73             break;
74                 }
75             }
76     }
77
78     // If we still didn't find a tabDesc, then we can't proceed
79
if (tabDesc == null) {
80         // FIXME: Provide a means to access Logging
81
throw new FrameworkException("No tabs defined for this page: "+
82         getName(), getViewDescriptor(), this);
83     }
84
85     // get the view bean in which to forward to
86
String JavaDoc viewBeanName = tabDesc.getViewBean(getRequestContext(), nodeID);
87     if (viewBeanName != null) {
88         ViewBean next = getViewBean(viewBeanName);
89         next.forwardTo(getRequestContext());
90         return;
91     } else {
92         // FIXME: Provide a means to access Logging
93
throw new FrameworkException("No nextPage defined for tab: "+
94         tabDesc.getName(), getViewDescriptor(), this);
95         }
96     }
97 }
98
Popular Tags