1 /*
2 * Copyright 2008 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.ole.sys.document.web.util;
17
18 import javax.servlet.jsp.PageContext;
19
20 import org.kuali.rice.kns.util.KNSGlobalVariables;
21 import org.kuali.rice.kns.util.WebUtils;
22 import org.kuali.rice.kns.web.struts.form.pojo.PojoFormBase;
23
24 /**
25 * This class contains utility methods to help render accounting line elements
26 */
27 public class RendererUtil {
28 /**
29 * Registers a property name as on a form/JSP page as editable so that when the next request is submitted,
30 * the property will be properly populated on the form
31 *
32 * @param pageContext
33 * @param editablePropertyName
34 */
35 public static void registerEditableProperty(PageContext pageContext, String editablePropertyName) {
36 PojoFormBase form = null;
37 if (pageContext.getRequest().getAttribute(WebUtils.KEY_KUALI_FORM_IN_SESSION) != null) {
38 form = (PojoFormBase) pageContext.getRequest().getAttribute(WebUtils.KEY_KUALI_FORM_IN_SESSION);
39 }
40 else if (pageContext.getSession().getAttribute(WebUtils.KEY_KUALI_FORM_IN_SESSION) != null) {
41 form = (PojoFormBase) pageContext.getSession().getAttribute(WebUtils.KEY_KUALI_FORM_IN_SESSION);
42 }
43 else {
44 form = (PojoFormBase) KNSGlobalVariables.getKualiForm();
45 }
46
47 if (form != null) {
48 form.registerEditableProperty(editablePropertyName);
49 }
50 }
51 }