1 23 24 package com.sun.enterprise.tools.guiframework.view.descriptors; 25 26 import com.iplanet.jato.RequestContext; 27 import com.iplanet.jato.RequestManager; 28 import com.iplanet.jato.view.ContainerView; 29 import com.iplanet.jato.view.View; 30 31 import com.sun.enterprise.tools.guiframework.exception.FrameworkException; 32 import com.sun.enterprise.tools.guiframework.view.DescriptorCCDateTime; 33 34 import com.sun.web.ui.model.CCDateTimeModelInterface; 35 36 import java.util.Date ; 37 import java.util.HashMap ; 38 import java.util.Map ; 39 40 41 44 public class CCDateTimeDescriptor extends DisplayFieldDescriptor { 45 46 49 public CCDateTimeDescriptor(String name) { 50 super(name); 51 } 52 53 56 public CCDateTimeModelInterface getModel() { 57 return getModel(RequestManager.getRequestContext()); 58 } 59 60 63 public CCDateTimeModelInterface getModel(RequestContext ctx) { 64 return (CCDateTimeModelInterface)ctx.getModelManager().getModel( 65 CCDateTimeModelInterface.class, 66 getModelInstanceName(), 67 shouldGetModelFromSession(), 68 shouldPutModelToSession()); 69 } 70 71 77 public View getInstance(RequestContext ctx, ContainerView container, String name) { 78 CCDateTimeModelInterface model = getModel(ctx); 80 81 if (model.getStartDateTime() == null) { 83 Date today = (Date )getParameter(START_DATE_TIME); 86 if (today == null) { 87 today = new Date (); 88 } 89 model.setStartDateTime(today); 90 91 94 model.setType(CCDateTimeModelInterface.START_DATE_TIME_ONLY); 96 97 String value = (String )getParameter(DATE_TIME_TYPE); 99 if (value != null) { 100 Integer type = (Integer )_typeMap.get(value); 101 if (type != null) { 102 model.setType(type.intValue()); 103 } else { 104 throw new FrameworkException("Invalid CCDateTime type!"); 105 } 106 } 107 108 model.setSelectedRepeatIntervalName(CCDateTimeModelInterface.WEEKLY); 110 111 value = (String )getParameter(SHOW_REQUIRED_MESSAGE); 116 boolean booleanValue = false; 117 if (value != null) { 118 booleanValue = new Boolean (value).booleanValue(); 119 } 120 model.setShowRequiredMsg(booleanValue); 121 122 value = (String )getParameter(START_DATE_LABEL); 124 if (value != null) { 125 model.setStartDateLabel(value); 126 } 127 128 value = (String )getParameter(START_TIME_LABEL); 130 if (value != null) { 131 model.setStartTimeLabel(value); 132 } 133 134 } 140 141 return new DescriptorCCDateTime(ctx, name, this, container, model); 143 } 146 147 150 private static Map _typeMap = new HashMap (); 151 152 static { 153 _typeMap.put("NORMAL", new Integer (CCDateTimeModelInterface.NORMAL)); 154 _typeMap.put("NO_END_TIME", new Integer (CCDateTimeModelInterface.NO_END_TIME)); 155 _typeMap.put("FOR_DATE_SELECTION", new Integer (CCDateTimeModelInterface.FOR_DATE_SELECTION)); 156 _typeMap.put("NO_REPEAT_LIMIT", new Integer (CCDateTimeModelInterface.NO_REPEAT_LIMIT)); 157 _typeMap.put("START_DATE_TIME_ONLY", new Integer (CCDateTimeModelInterface.START_DATE_TIME_ONLY)); 158 } 159 160 163 public static final String START_DATE_TIME = "startDateTime"; 164 165 168 public static final String START_DATE_LABEL = "startDateLabel"; 169 170 173 public static final String START_TIME_LABEL = "startTimeLabel"; 174 175 179 public static final String END_TIME_LABEL = "endTimeLabel"; 180 181 185 public static final String SHOW_REQUIRED_MESSAGE = "showRequiredMessage"; 186 187 197 public static final String DATE_TIME_TYPE = "type"; 198 } 199 | Popular Tags |