1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.document.service.impl;
17
18 import java.util.Map;
19
20 import org.kuali.ole.sys.businessobject.AccountingLine;
21 import org.kuali.ole.sys.document.service.AccountingLineFieldRenderingTransformation;
22 import org.kuali.rice.kns.datadictionary.MaintainableFieldDefinition;
23 import org.kuali.rice.kns.web.ui.Field;
24 import org.kuali.rice.krad.valuefinder.ValueFinder;
25
26
27
28
29 public class DefaultValuePopulationAccountingLineFieldRenderingTransformationImpl implements AccountingLineFieldRenderingTransformation {
30
31
32
33
34
35
36 public void transformField(AccountingLine accountingLine, Field field, MaintainableFieldDefinition fieldDefinition, Map unconvertedValues) {
37 populateFieldWithDefault(field, fieldDefinition);
38 }
39
40
41
42
43
44
45
46
47 protected void populateFieldWithDefault(Field field, MaintainableFieldDefinition fieldDefinition) {
48 try {
49 Class defaultValueFinderClass = fieldDefinition.getDefaultValueFinderClass();
50 if (defaultValueFinderClass != null) {
51 field.setPropertyValue(((ValueFinder) defaultValueFinderClass.newInstance()).getValue());
52 }
53 }
54 catch (InstantiationException ie) {
55 throw new RuntimeException("Default Value Finder Class "+fieldDefinition.getDefaultValueFinderClass().getName()+" for property "+field.getPropertyName()+" could not be instantiated");
56 }
57 catch (IllegalAccessException e) {
58 throw new RuntimeException("Default Value Finder Class "+fieldDefinition.getDefaultValueFinderClass().getName()+" for property "+field.getPropertyName()+" was accessed illegally");
59 }
60 }
61 }