1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.fp.document.web.struts;
17
18 import javax.servlet.http.HttpServletRequest;
19 import javax.servlet.http.HttpServletResponse;
20
21 import org.apache.struts.action.ActionForm;
22 import org.apache.struts.action.ActionForward;
23 import org.apache.struts.action.ActionMapping;
24 import org.kuali.ole.fp.businessobject.InternalBillingItem;
25 import org.kuali.ole.sys.OLEConstants;
26 import org.kuali.ole.sys.OLEPropertyConstants;
27 import org.kuali.ole.sys.context.SpringContext;
28 import org.kuali.rice.kns.service.DictionaryValidationService;
29
30
31
32
33 public class InternalBillingAction extends CapitalAccountingLinesActionBase {
34
35
36
37
38
39
40
41
42
43
44
45 public ActionForward insertItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
46 InternalBillingForm internalBillingForm = (InternalBillingForm) form;
47 if (validateNewItem(internalBillingForm)) {
48 internalBillingForm.getInternalBillingDocument().addItem(internalBillingForm.getNewItem());
49 internalBillingForm.setNewItem(new InternalBillingItem());
50 }
51 return mapping.findForward(OLEConstants.MAPPING_BASIC);
52 }
53
54
55
56
57
58
59
60 protected static boolean validateNewItem(InternalBillingForm internalBillingForm) {
61 return SpringContext.getBean(DictionaryValidationService.class).isBusinessObjectValid(internalBillingForm.getNewItem(), OLEPropertyConstants.NEW_ITEM);
62 }
63
64
65
66
67
68
69
70
71
72
73
74 public ActionForward deleteItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
75 InternalBillingForm internalBillingForm = (InternalBillingForm) form;
76 internalBillingForm.getInternalBillingDocument().getItems().remove(getLineToDelete(request));
77 return mapping.findForward(OLEConstants.MAPPING_BASIC);
78 }
79 }