View Javadoc

1   /**
2    * Copyright 2013 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   *
15   * Created by David Yin on 1/16/13
16   */
17  package org.kuali.student.common.uif.form;
18  
19  import org.apache.commons.lang.StringUtils;
20  import org.kuali.rice.krad.web.form.UifFormBase;
21  import org.kuali.student.common.uif.util.GrowlIcon;
22  import org.kuali.student.common.uif.util.KSUifUtils;
23  import org.kuali.student.r2.common.dto.MetaInfo;
24  import org.kuali.student.r2.common.util.date.DateFormatters;
25  import org.kuali.student.r2.common.util.date.KSDateTimeFormatter;
26  
27  import javax.servlet.http.HttpServletRequest;
28  
29  /**
30   * KS form class that extends UifFormBase. It contains properties that are shared
31   * among all the KS forms.
32   *
33   * @author Kuali Student Team
34   */
35  public class KSUifForm extends UifFormBase {
36  
37      MetaInfo meta = new MetaInfo();
38      KSDateTimeFormatter defaultFormatter = DateFormatters.COURSE_OFFERING_VIEW_HELPER_DATE_TIME_FORMATTER;
39  
40      public KSUifForm() {
41          super();
42      }
43  
44      public MetaInfo getMeta() {
45          return meta;
46      }
47  
48      public void setMeta(MetaInfo meta) {
49          this.meta = meta;
50      }
51  
52      public KSDateTimeFormatter getDefaultFormatter() {
53          return defaultFormatter;
54      }
55  
56      public void setDefaultFormatter(KSDateTimeFormatter defaultFormatter) {
57          this.defaultFormatter = defaultFormatter;
58      }
59  
60      public String getVersionInd(){
61          if (StringUtils.isEmpty(meta.getVersionInd())){
62              return "";
63          } else {
64              return  meta.getVersionInd();
65          }
66  
67      }
68  
69      public String getCreateTime(){
70          if(meta.getCreateTime() == null){
71              return "";
72          } else {
73              return getDefaultFormatter().format(meta.getCreateTime());
74          }
75      }
76  
77      public String getUpdateTime(){
78          if(meta.getUpdateTime() == null){
79              return "";
80          } else {
81              return getDefaultFormatter().format(meta.getUpdateTime());
82          }
83      }
84  
85      public String getCreateId(){
86          if(StringUtils.isEmpty(meta.getCreateId() )){
87              return "";
88          } else {
89              return meta.getCreateId();
90          }
91  
92      }
93      public String getUpdateId(){
94          if(StringUtils.isEmpty(meta.getUpdateId() )){
95              return "";
96          } else {
97              return meta.getUpdateId();
98          }
99  
100     }
101 
102     @Override
103     public void postBind(HttpServletRequest request) {
104 
105         String growlMessage = request.getParameter("growl.message");
106         String temp = request.getParameter("growl.message.params");
107         String[] growlMessageParams;
108         if(temp!=null){
109             growlMessageParams = temp.split(",");
110         }
111         else{
112             growlMessageParams=new String[0];
113         }
114 
115         if (growlMessage != null) {
116               KSUifUtils.addGrowlMessageIcon(GrowlIcon.SUCCESS, growlMessage, growlMessageParams);
117         }
118 
119         super.postBind(request);
120     }
121 
122 }