1 23 24 package com.sun.enterprise.tools.guiframework.view.descriptors; 25 26 import com.iplanet.jato.ModelManager; 27 import com.iplanet.jato.RequestContext; 28 import com.iplanet.jato.view.ContainerView; 29 import com.iplanet.jato.view.View; 30 import com.iplanet.jato.view.DisplayField; 31 import com.iplanet.jato.RequestManager; 32 import com.iplanet.jato.view.ContainerViewBase; 33 34 import com.sun.enterprise.tools.guiframework.exception.FrameworkException; 35 import com.sun.enterprise.tools.guiframework.view.DescriptorCCActionTable; 36 37 import com.sun.web.ui.model.CCActionTableModelInterface; 38 39 import java.io.InputStream ; 40 41 42 45 public class CCActionTableDescriptor extends ViewDescriptor { 46 47 50 public CCActionTableDescriptor(String name) { 51 super(name); 52 } 53 54 55 public void registerChildren(ContainerViewBase instance) { 56 super.registerChildren(instance); 58 59 getModel().registerChildren(instance); 60 } 61 62 63 67 public ViewDescriptor getChildDescriptor(String name) { 68 ViewDescriptor desc = super.getChildDescriptor(name); 70 if (desc != null) { 71 return desc; 72 } 73 74 CCActionTableModelInterface model = getModel(); 76 if (model != null && model.isChildSupported(name)) { 77 desc = new CCActionTableChildDescriptor(name); 79 addChildDescriptor(desc); 86 return desc; 87 } 88 89 return null; 90 } 91 92 98 public View getInstance(RequestContext ctx, ContainerView container, String name) { 99 return new DescriptorCCActionTable(ctx, container, name, this, getModel()); 100 } 101 102 105 public void resetXML() { 106 getModel(true); 107 } 108 109 112 public CCActionTableModelInterface getModel() { 113 return getModel(false); 114 } 115 116 private CCActionTableModelInterface getModel(boolean resetXML) { 117 boolean fromSession = shouldGetModelFromSession(); 119 boolean toSession = shouldPutModelToSession(); 120 String value = getModelInstanceName(); 121 122 ModelManager mgr = RequestManager.getRequestContext().getModelManager(); 124 CCActionTableModelInterface model = 125 (CCActionTableModelInterface)mgr.getModel( 126 CCActionTableModelInterface.class, 127 value, fromSession, toSession); 128 129 if (resetXML || model.getDocument() == null) { 131 InputStream in = getXMLFileAsStream(); 133 model.setDocument(in); 134 try { 135 in.close(); 136 } catch (java.io.IOException ex) { 137 } 139 140 143 value = (String )getParameter(PRIMARY_SORT_NAME); 145 if (value != null) { 146 model.setPrimarySortName(value); 147 } 148 149 value = (String )getParameter(PRIMARY_SORT_ORDER); 151 if (value != null) { 152 model.setPrimarySortOrder(value); 153 } 154 155 value = (String )getParameter(SECONDARY_SORT_NAME); 157 if (value != null) { 158 model.setSecondarySortName(value); 159 } 160 161 value = (String )getParameter(SECONDARY_SORT_ORDER); 163 if (value != null) { 164 model.setSecondarySortOrder(value); 165 } 166 } 167 168 value = (String )getParameter(ROW_SELECTION_TYPE); 170 if (value != null) { 171 model.setRowSelectionType(value); 172 } 173 174 return model; 175 } 176 177 187 public static final String ROW_SELECTION_TYPE = "rowSelectionType"; 188 189 192 public static final String PRIMARY_SORT_NAME = "primarySortName"; 193 194 202 public static final String PRIMARY_SORT_ORDER = "primarySortOrder"; 203 204 207 public static final String SECONDARY_SORT_NAME = "secondarySortName"; 208 209 217 public static final String SECONDARY_SORT_ORDER = "secondarySortOrder"; 218 } 219 | Popular Tags |