1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.demo.uif.controller;
17
18 import org.kuali.rice.krad.util.GlobalVariables;
19 import org.kuali.rice.krad.web.form.DialogResponse;
20 import org.kuali.rice.krad.web.form.UifFormBase;
21 import org.springframework.stereotype.Controller;
22 import org.springframework.web.bind.annotation.ModelAttribute;
23 import org.springframework.web.bind.annotation.RequestMapping;
24 import org.springframework.web.servlet.ModelAndView;
25
26
27
28
29
30
31 @Controller
32 @RequestMapping(value = "/dialog")
33 public class DemoDialogController extends KradSampleAppController {
34
35 protected static final String DEMO_DUPLICATE_DIALOG = "Demo-DialogGroup-ServerResponse1";
36 protected static final String DEMO_DISAPPROVE_CONFIRM = "Demo-DialogGroup-ServerResponse2";
37 protected static final String DEMO_DISAPPROVE_SURVEY = "Demo-DialogGroup-ServerResponse3";
38
39 @RequestMapping(params = "methodToCall=save")
40 @Override
41 public ModelAndView save(@ModelAttribute("KualiForm") UifFormBase form) throws Exception {
42
43 DialogResponse duplicateDialogResponse = form.getDialogResponse(DEMO_DUPLICATE_DIALOG);
44 if (duplicateDialogResponse == null) {
45 return showDialog(DEMO_DUPLICATE_DIALOG, true, form);
46 }
47
48 boolean verifiedDuplicate = duplicateDialogResponse.getResponseAsBoolean();
49 if (verifiedDuplicate) {
50
51 GlobalVariables.getMessageMap().putInfoForSectionId("demoDialogEx8", "demo.dialogs.saveConfirmation");
52 }
53
54 return getModelAndView(form);
55 }
56
57 @RequestMapping(params = "methodToCall=disapprove")
58 public ModelAndView disapprove(@ModelAttribute("KualiForm") UifFormBase form) throws Exception {
59
60 DialogResponse disapproveConfirm = form.getDialogResponse(DEMO_DISAPPROVE_CONFIRM);
61 if (disapproveConfirm == null) {
62 return showDialog(DEMO_DISAPPROVE_CONFIRM, true, form);
63 }
64
65
66
67 String disapproveExplanation = disapproveConfirm.getExplanation();
68
69 DialogResponse disapproveSurvey = form.getDialogResponse(DEMO_DISAPPROVE_SURVEY);
70 if (disapproveSurvey == null) {
71 return showDialog(DEMO_DISAPPROVE_SURVEY, false, form);
72 }
73
74 String surveyResponse = disapproveSurvey.getResponse();
75
76 GlobalVariables.getMessageMap().putInfoForSectionId("demoDialogEx9", "demo.dialogs.disapprove",
77 disapproveExplanation, surveyResponse);
78
79 return getModelAndView(form);
80 }
81 }