View Javadoc
1   /**
2    * Copyright 2005-2016 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.rice.krad.uif.view;
17  
18  import org.kuali.rice.krad.datadictionary.parse.BeanTag;
19  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20  import org.kuali.rice.krad.datadictionary.parse.BeanTags;
21  
22  /**
23   * Provides configuration for <code>View</code> instances that render an HTML
24   * form
25   *
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   */
28  @BeanTags({@BeanTag(name = "formView-bean", parent = "Uif-FormView"),
29          @BeanTag(name = "formView-knsTheme-bean", parent = "Uif-FormView-KnsTheme"),
30          @BeanTag(name = "incidentReportView-bean", parent = "Uif-IncidentReportView"),
31          @BeanTag(name = "initiatedDocumentView-bean", parent = "InitiatedDocumentView"),
32          @BeanTag(name = "initiatedDocumentView-KNS-bean", parent = "InitiatedDocumentView-KNS")})
33  public class FormView extends View {
34      private static final long serialVersionUID = -3291164284675273147L;
35  
36      private boolean renderForm;
37      private boolean validateServerSide;
38      private boolean validateClientSide;
39  
40      private String formPostUrl;
41  
42      public FormView() {
43          renderForm = true;
44          validateServerSide = true;
45          validateClientSide = true;
46          setApplyDirtyCheck(true);
47      }
48  
49      /**
50       * Indicates whether a Form element should be rendered for the View. This is
51       * necessary for pages that need to submit data back to the server. Note
52       * that even if a page is read-only, a form element is generally needed for
53       * the navigation. Defaults to true
54       *
55       * @return true if the form element should be rendered, false if it should
56       *         not be
57       */
58      @BeanTagAttribute(name = "renderForm")
59      public boolean isRenderForm() {
60          return this.renderForm;
61      }
62  
63      /**
64       * Setter for the render form indicator
65       *
66       * @param renderForm
67       */
68      public void setRenderForm(boolean renderForm) {
69          this.renderForm = renderForm;
70      }
71  
72      /**
73       * Indicates whether to perform the validate model phase of the view
74       * lifecycle. This phase will validate the model against configured
75       * dictionary validations and report errors. Defaults to true
76       *
77       * @return boolean true if model data should be validated, false if it
78       *         should not be
79       */
80      @BeanTagAttribute(name = "validateServerSide")
81      public boolean isValidateServerSide() {
82          return this.validateServerSide;
83      }
84  
85      /**
86       * Setter for the validate server side indicator
87       *
88       * @param validateServerSide
89       */
90      public void setValidateServerSide(boolean validateServerSide) {
91          this.validateServerSide = validateServerSide;
92      }
93  
94      /**
95       * Indicates whether to perform on-the-fly validation on the client using js
96       * during user data entry. Defaults to true
97       *
98       * @return the validateClientSide
99       */
100     @BeanTagAttribute(name = "validateClientSide")
101     public boolean isValidateClientSide() {
102         return validateClientSide;
103     }
104 
105     /**
106      * Setter for the validate client side indicator
107      *
108      * @param validateClientSide
109      */
110     public void setValidateClientSide(boolean validateClientSide) {
111         this.validateClientSide = validateClientSide;
112     }
113 
114     /**
115      * Specifies the URL the view's form should post to
116      *
117      * <p>
118      * Any valid form post URL (full or relative) can be specified. If left
119      * empty, the form will be posted to the same URL of the preceding request
120      * URL.
121      * </p>
122      *
123      * @return post URL
124      */
125     @BeanTagAttribute(name = "formPostUrl")
126     public String getFormPostUrl() {
127         return this.formPostUrl;
128     }
129 
130     /**
131      * Setter for the form post URL
132      *
133      * @param formPostUrl
134      */
135     public void setFormPostUrl(String formPostUrl) {
136         this.formPostUrl = formPostUrl;
137     }
138 
139     /**
140      * @see org.kuali.rice.krad.uif.component.ComponentBase#copy()
141      */
142     @Override
143     protected <T> void copyProperties(T component) {
144         super.copyProperties(component);
145         FormView formViewCopy = (FormView) component;
146         formViewCopy.setRenderForm(this.isRenderForm());
147         formViewCopy.setValidateServerSide(this.isValidateServerSide());
148         formViewCopy.setValidateClientSide(this.isValidateClientSide());
149         formViewCopy.setFormPostUrl(this.getFormPostUrl());
150     }
151 }