1 package org.kuali.ole.deliver.controller;
2
3 import org.apache.commons.lang3.StringUtils;
4 import org.kuali.rice.krad.uif.UifConstants;
5 import org.kuali.rice.krad.web.controller.UifControllerBase;
6 import org.kuali.rice.krad.web.form.UifFormBase;
7 import org.springframework.web.servlet.ModelAndView;
8
9
10
11
12 public abstract class OLEUifControllerBase extends UifControllerBase {
13
14 protected ModelAndView showLightBoxForUrl(String url, UifFormBase form) {
15 form.setLightboxScript("openLightboxUrl('" + url +"');");
16 return getUIFModelAndView(form);
17 }
18
19 protected ModelAndView showLightBoxForUrlWichCustomScript(String url, UifFormBase form,String customScript) {
20 form.setLightboxScript("openLightboxUrl('" + url +"');"+ (StringUtils.isNotBlank(customScript) ? customScript + ";" : ""));
21 return getUIFModelAndView(form);
22 }
23
24 protected ModelAndView showIFrameDialog(String url, UifFormBase form, String customScript) {
25 String script = "var iframeDialog = jq('<div></div>')\n" +
26 " .html('<iframe style=\"border: 0px; \" src=\"" + url +"\" width=\"100%\" height=\"100%\"></iframe>')\n" +
27 " .dialog({\n" +
28 " autoOpen: false,\n" +
29 " modal: true,\n" +
30 " height: 800,\n" +
31 " width: 700,\n" +
32 " close: function( event, ui ) {" + customScript + "}\n " +
33 " });\n" +
34 "iframeDialog.dialog('open');";
35 form.setLightboxScript(script);
36 return getUIFModelAndView(form);
37 }
38
39 protected ModelAndView closeLightBoxForUrl(UifFormBase form) {
40 form.setLightboxScript("jq.fancybox.close();");
41 return getUIFModelAndView(form);
42 }
43
44 protected ModelAndView executeCustomScriptAfterClosingLightBox(UifFormBase form,String customScript) {
45 form.setLightboxScript("closeLightbox();"+ (StringUtils.isNotBlank(customScript) ? customScript + ";" : ""));
46 return getUIFModelAndView(form);
47 }
48
49 protected ModelAndView executeCustomScriptBeforeClosingLightBox(UifFormBase form,String customScript) {
50 form.setLightboxScript((StringUtils.isNotBlank(customScript) ? customScript + ";" : "") + "closeLightbox();");
51 return getUIFModelAndView(form);
52 }
53
54 protected ModelAndView showDialogAndRunCustomScript(String dialogId,UifFormBase form, String customScript) {
55 form.setLightboxScript("openLightboxOnLoad('" + dialogId + "');"+ (StringUtils.isNotBlank(customScript) ? customScript + ";" : ""));
56 form.getDialogManager().addDialog(dialogId, form.getMethodToCall());
57 if (form.isAjaxRequest()) {
58 form.setAjaxReturnType(UifConstants.AjaxReturnTypes.UPDATEDIALOG.getKey());
59 form.setUpdateComponentId(dialogId);
60 }
61
62 return getUIFModelAndView(form);
63 }
64 }