1 23 24 package com.sun.enterprise.tools.guiframework.event.handlers; 25 26 import com.iplanet.jato.RequestContext; 27 import com.iplanet.jato.view.event.ChildContentDisplayEvent; 28 import com.sun.web.ui.taglib.html.CCTextFieldTag; 29 import com.sun.web.ui.taglib.html.CCTextAreaTag; 30 31 import com.sun.enterprise.tools.guiframework.view.HandlerContext; 32 import com.sun.enterprise.tools.guiframework.view.ViewDescriptorManager; 33 import com.sun.enterprise.tools.guiframework.view.descriptors.ViewDescriptor; 34 35 import java.util.ArrayList ; 36 import java.util.Iterator ; 37 import java.util.List ; 38 import java.util.Map ; 39 import java.util.Stack ; 40 41 42 45 public class ViewDescriptorHandlers { 46 47 56 public void getHierarchy(RequestContext reqCtx, HandlerContext handlerCtx) { 57 ViewDescriptor topViewDesc = handlerCtx.getViewDescriptor(); 59 60 Stack nameStack = new Stack (); 62 63 do { 65 nameStack.push(topViewDesc.getName()); 66 topViewDesc = topViewDesc.getParent(); 67 } while (topViewDesc != null); 68 69 70 List path = new ArrayList (); 72 while (!nameStack.empty()) { 73 path.add(nameStack.pop()); 74 } 75 76 handlerCtx.setOutputValue(VALUE, path); 78 } 79 80 81 96 public void getViewDescriptorParameter(RequestContext reqCtx, HandlerContext handlerCtx) { 97 Object paramName = handlerCtx.getInputValue(PARAMETER_NAME); 100 if (paramName == null) { 101 throw new IllegalArgumentException ( 102 "No 'Parameter Name' Specified!"); 103 } 104 105 ViewDescriptor viewDesc = null; 106 Object vdName = handlerCtx.getInputValue(VIEW_DESCRIPTOR_NAME); 107 if (vdName == null) { 108 viewDesc = handlerCtx.getViewDescriptor(); 110 } else { 111 ViewDescriptorManager mgr = ViewDescriptorManager.getInstance(); 113 114 if (vdName instanceof List ) { 116 Iterator it = ((List )vdName).iterator(); 118 String key = it.next().toString(); 119 viewDesc = mgr.getViewDescriptor(key); 120 if (viewDesc == null) { 121 throw new IllegalArgumentException ( 122 "Top-level ViewDescriptor '"+key+"' not found!"); 123 } 124 while (it.hasNext()) { 125 key = it.next().toString(); 126 viewDesc = viewDesc.getChildDescriptor(key); 127 if (viewDesc == null) { 128 throw new IllegalArgumentException ( 129 "Child ViewDescriptor '"+key+"' not found!"); 130 } 131 } 132 } else { 133 viewDesc = mgr.getViewDescriptor(vdName.toString()); 135 if (viewDesc == null) { 136 throw new IllegalArgumentException ( 137 "Top-level ViewDescriptor '"+vdName.toString()+ 138 "' not found!"); 139 } 140 } 141 } 142 143 Object value = null; 145 if (paramName instanceof List ) { 146 List paramList = (List )paramName; 147 ArrayList paramValueList = new ArrayList (); 148 for (int i = 0; i < paramList.size(); i++) { 149 paramValueList.add(viewDesc.getParameter((String )paramList.get(i))); 150 } 151 value = paramValueList; 152 } else { 153 value = viewDesc.getParameter(paramName.toString()); 154 } 155 156 handlerCtx.setOutputValue(VALUE, value); 158 } 159 160 216 public void beginFixTextDisplay(RequestContext ctx, HandlerContext handlerCtx) { 217 Object tag = handlerCtx.getEvent().getSource(); 218 if (tag instanceof CCTextFieldTag) { 219 ((CCTextFieldTag)tag).setLocalizeDisplayFieldValue("false"); 220 } 221 else if (tag instanceof CCTextAreaTag) { 222 ((CCTextAreaTag)tag).setLocalizeDisplayFieldValue("false"); 223 } 224 } 225 226 public static final String VIEW_DESCRIPTOR_NAME = "ViewDescriptorName"; 227 public static final String PARAMETER_NAME = "ParameterName"; 228 public static final String VALUE = "value"; 229 } 230 | Popular Tags |