View Javadoc

1   /**
2    * Copyright 2005-2013 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.container;
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  import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
22  import org.kuali.rice.krad.uif.component.Component;
23  import org.kuali.rice.krad.uif.view.FormView;
24  import org.kuali.rice.krad.uif.view.View;
25  
26  /**
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  @BeanTags({@BeanTag(name = "page-bean", parent = "Uif-Page"),
30          @BeanTag(name = "disclosure-page-bean", parent = "Uif-Disclosure-Page"),
31          @BeanTag(name = "documentPage-bean", parent = "Uif-DocumentPage"),
32          @BeanTag(name = "inquiryPage-bean", parent = "Uif-InquiryPage"),
33          @BeanTag(name = "lookupPage-bean", parent = "Uif-LookupPage"),
34          @BeanTag(name = "maintenancePage-bean", parent = "Uif-MaintenancePage")})
35  public class PageGroup extends Group {
36      private static final long serialVersionUID = 7571981300587270274L;
37  
38      private boolean autoFocus = false;
39  
40      /**
41       * Perform finalize here adds to its document ready script the
42       * setupValidator js function for setting up the validator for this view.
43       *
44       * @see org.kuali.rice.krad.uif.container.ContainerBase#performFinalize(org.kuali.rice.krad.uif.view.View,
45       *      java.lang.Object, org.kuali.rice.krad.uif.component.Component)
46       */
47      @Override
48      public void performFinalize(View view, Object model, Component parent) {
49          super.performFinalize(view, model, parent);
50  
51          this.addDataAttribute("type", "Page");
52  
53          String prefixScript = "";
54          if (this.getOnDocumentReadyScript() != null) {
55              prefixScript = this.getOnDocumentReadyScript();
56          }
57  
58          if (view instanceof FormView && ((FormView) view).isValidateClientSide()) {
59              this.setOnDocumentReadyScript(prefixScript + "\nsetupPage(true);");
60          } else {
61              this.setOnDocumentReadyScript(prefixScript + "\nsetupPage(false);");
62          }
63      }
64  
65      /**
66       * When this is true, the first field of the kualiForm will be focused by
67       * default, unless the parameter focusId is set on the form (by an
68       * actionField), then that field will be focused instead. When this setting
69       * if false, no field will be focused.
70       *
71       * @return the autoFocus
72       */
73      @BeanTagAttribute(name = "autoFocus")
74      public boolean isAutoFocus() {
75          return this.autoFocus;
76      }
77  
78      /**
79       * @param autoFocus the autoFocus to set
80       */
81      public void setAutoFocus(boolean autoFocus) {
82          this.autoFocus = autoFocus;
83      }
84  
85      /**
86       * @see org.kuali.rice.krad.uif.component.Component#completeValidation
87       */
88      @Override
89      public void completeValidation(ValidationTrace tracer) {
90          tracer.addBean(this);
91  
92          // Checks that no invalid items are present
93          for (int i = 0; i < getItems().size(); i++) {
94              if (getItems().get(i).getClass() == PageGroup.class || getItems().get(i).getClass()
95                      == NavigationGroup.class) {
96                  String currentValues[] = {"item(" + i + ").class =" + getItems().get(i).getClass()};
97                  tracer.createError("Items in PageGroup cannot be PageGroup or NaviagtionGroup", currentValues);
98              }
99          }
100 
101         super.completeValidation(tracer.getCopy());
102     }
103 }