1 23 24 package com.sun.enterprise.tools.guiframework.view.descriptors; 25 26 import com.iplanet.jato.RequestContext; 27 import com.iplanet.jato.model.ModelFieldBinding; 28 import com.iplanet.jato.view.BasicDisplayField; 29 import com.iplanet.jato.view.DisplayFieldImpl; 30 import com.iplanet.jato.view.ContainerView; 31 import com.iplanet.jato.view.DisplayField; 32 import com.iplanet.jato.view.View; 33 import com.iplanet.jato.view.ViewBean; 34 import com.iplanet.jato.view.event.DisplayEvent; 35 import com.iplanet.jato.view.html.HtmlDisplayFieldBase; 36 37 import java.util.ArrayList ; 38 import java.util.List ; 39 40 41 44 public class DisplayFieldDescriptor extends ViewDescriptor { 45 46 52 public DisplayFieldDescriptor(String name) { 53 super(name); 54 } 55 56 57 61 protected void setDefaultValue(View view) { 62 Object value = getInitialValue(); 66 if (value != null) { 67 if (view instanceof DisplayField) { 68 DisplayField df = ((DisplayField)view); 69 if (df.getValue() == null) { 70 df.setValue(value); 72 } 73 } 74 } 75 } 76 77 78 81 public View getInstance(RequestContext ctx, ContainerView container, String name) { 82 BasicDisplayField field = new BasicDisplayField(container, name); 84 85 setModelFieldBinding(field, getModelFieldName()); 87 88 setDefaultValue(field); 90 91 return field; 92 } 93 94 95 102 public String getModelFieldName() { 103 String value = (String )getParameter(MODEL_FIELD_NAME); 104 if (value == null) { 105 value = getName(); 106 } 107 return value; 108 } 109 110 119 public void setBoundName(DisplayField field) { 120 if (field instanceof DisplayFieldImpl) { 121 setBoundName((DisplayFieldImpl)field, getModelFieldName()); 122 } else if (field instanceof BasicDisplayField) { 123 setModelFieldBinding((BasicDisplayField)field, getModelFieldName()); 124 } 125 } 126 127 134 public void setBoundName(DisplayFieldImpl field, String name) { 135 field.setBoundName(name); 136 } 137 138 145 public void setModelFieldBinding(BasicDisplayField field, String name) { 146 field.setModelFieldBinding(new ModelFieldBinding(name)); 147 } 148 149 156 public Object getInitialValue() { 157 return getParameter(DEFAULT_VALUE); 158 } 159 160 161 169 public String setExtraHtml(HtmlDisplayFieldBase view) { 170 String extra = (String )getParameter(EXTRA_HTML); 173 if ((extra != null) && (view != null)) { 174 view.setExtraHtml(extra); 175 } 176 return extra; 177 } 178 179 183 public boolean isDisabled() { 184 return Boolean.parseBoolean((""+getParameter(DISABLED)).toString()); 185 } 186 187 191 public static final String DISABLED = "disabled"; 192 193 194 195 201 public static final String MODEL_FIELD_NAME= "modelFieldName"; 202 203 208 public static final String DEFAULT_VALUE = "defaultValue"; 209 210 211 215 public static final String EXTRA_HTML = "extraHtml"; 216 } 217 | Popular Tags |