1 23 24 package com.sun.enterprise.tools.guiframework.event.handlers; 25 26 import com.iplanet.jato.RequestContext; 27 import com.iplanet.jato.ViewBeanManager; 28 import com.iplanet.jato.view.ContainerView; 29 import com.iplanet.jato.view.View; 30 31 import com.sun.enterprise.tools.guiframework.view.HandlerContext; 32 import com.sun.enterprise.tools.guiframework.exception.FrameworkException; 33 import com.sun.enterprise.tools.guiframework.view.DescriptorViewManager; 34 35 import java.util.Iterator ; 36 import java.util.List ; 37 import java.util.Map ; 38 39 40 43 public class ViewHandlers { 44 45 54 public void getView(RequestContext reqCtx, HandlerContext handlerCtx) { 55 Object viewID = handlerCtx.getInputValue(VIEW_ID); 57 if (viewID == null) { 58 throw new FrameworkException( 59 "The parameter map did not contain "+VIEW_ID+"!"); 60 } 61 62 ViewBeanManager vm = reqCtx.getViewBeanManager(); 64 View view = null; 65 String topName = (viewID instanceof List ) ? 66 ((List )viewID).get(0).toString() : viewID.toString(); 67 try { 68 view = vm.getViewBean(topName); 69 } catch (ClassCastException ex) { 70 view = ((DescriptorViewManager)vm).getView(null, topName); 71 } catch (ClassNotFoundException ex) { 72 throw new FrameworkException(ex); 73 } 74 if (view == null) { 75 throw new FrameworkException( 76 "Unable to obtain the view for mapping!"); 77 } 78 79 if (viewID instanceof List ) { 81 Iterator iter = ((List )viewID).iterator(); 82 iter.next(); while (iter.hasNext()) { 84 if (!(view instanceof ContainerView)) { 85 throw new FrameworkException("View ("+ 86 view.getQualifiedName()+") is not a ContainerView!", 87 null, view); 88 } 89 view = ((ContainerView)view).getChild(""+iter.next()); 90 } 91 } 92 93 handlerCtx.setOutputValue(VALUE, view); 95 } 96 97 98 110 public void getQualifiedName(RequestContext reqCtx, HandlerContext handlerCtx) { 111 View view = (View)handlerCtx.getOutputValue(VIEW); 112 if (view == null) { 113 getView(reqCtx, handlerCtx); 115 view = (View)handlerCtx.getOutputValue(VALUE); 116 } 117 118 String leaf = (String )handlerCtx.getInputValue(LEAF_VIEW); 119 if (leaf != null) { 120 view = ((ContainerView)view).getChild(leaf); 121 } 122 123 handlerCtx.setOutputValue(VALUE, view.getQualifiedName()); 125 } 126 127 128 131 public static final String VALUE = "value"; 132 133 136 public static final String VIEW = "view"; 137 138 141 public static final String VIEW_ID = "viewID"; 142 143 146 public static final String LEAF_VIEW = "leafView"; 147 } 148 | Popular Tags |