Coverage Report - org.kuali.rice.krad.uif.container.PageGroup
 
Classes in this File Line Coverage Branch Coverage Complexity
PageGroup
0%
0/42
0%
0/30
6
 
 1  
 /*
 2  
  * e * Copyright 2011 The Kuali Foundation Licensed under the Educational
 3  
  * Community License, Version 1.0 (the "License"); you may not use this file
 4  
  * except in compliance with the License. You may obtain a copy of the License
 5  
  * at http://www.opensource.org/licenses/ecl1.php Unless required by applicable
 6  
  * law or agreed to in writing, software distributed under the License is
 7  
  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 8  
  * KIND, either express or implied. See the License for the specific language
 9  
  * governing permissions and limitations under the License.
 10  
  */
 11  
 package org.kuali.rice.krad.uif.container;
 12  
 
 13  
 import org.apache.commons.lang.StringUtils;
 14  
 import org.kuali.rice.core.api.config.property.ConfigurationService;
 15  
 import org.kuali.rice.krad.service.KRADServiceLocator;
 16  
 import org.kuali.rice.krad.uif.core.Component;
 17  
 import org.kuali.rice.krad.uif.widget.GrowlsWidget;
 18  
 import org.kuali.rice.krad.util.ErrorMessage;
 19  
 import org.kuali.rice.krad.util.GlobalVariables;
 20  
 import org.kuali.rice.krad.util.MessageMap;
 21  
 import org.springframework.util.AutoPopulatingList;
 22  
 
 23  
 import java.text.MessageFormat;
 24  
 import java.util.List;
 25  
 
 26  
 /**
 27  
  * This is a description of what this class does - Administrator don't forget to
 28  
  * fill this in.
 29  
  * 
 30  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 31  
  */
 32  0
 public class PageGroup extends Group {
 33  
     private static final long serialVersionUID = 7571981300587270274L;
 34  
 
 35  
     private boolean autoFocus;
 36  
 
 37  
     /**
 38  
      * Perform finalize here adds to its document ready script the
 39  
      * setupValidator js function for setting up the validator for this view.
 40  
      * 
 41  
      * @see org.kuali.rice.krad.uif.container.ContainerBase#performFinalize(org.kuali.rice.krad.uif.container.View,
 42  
      *      java.lang.Object, org.kuali.rice.krad.uif.core.Component)
 43  
      */
 44  
     @Override
 45  
     public void performFinalize(View view, Object model, Component parent) {
 46  0
         super.performFinalize(view, model, parent);
 47  
         
 48  0
         String prefixScript = "";
 49  0
         if (this.getOnDocumentReadyScript() != null) {
 50  0
             prefixScript = this.getOnDocumentReadyScript();
 51  
         }
 52  
         //Growls are setup here because they are relavant to the current page, but their
 53  
         //settings are global to the view
 54  0
         String growlScript = "";
 55  0
         if(view.isGrowlMessagingEnabled()){
 56  0
             GrowlsWidget gw = view.getGrowlsWidget();
 57  
 
 58  
             //Setup defaults
 59  0
             if(!gw.getComponentOptions().isEmpty()){
 60  0
                 growlScript = "setGrowlDefaults("+ gw.getComponentOptionsJSString() + ");";
 61  
             }
 62  
             
 63  0
             ConfigurationService configService = KRADServiceLocator.getKualiConfigurationService();
 64  0
             MessageMap messageMap = GlobalVariables.getMessageMap();
 65  0
             if(messageMap.hasErrors()){
 66  0
                 String message = configService.getPropertyString("growl.hasErrors");
 67  0
                 if(StringUtils.isNotBlank(message)){
 68  0
                     growlScript = growlScript + "showGrowl('" + message + "', '"+ configService.getPropertyString("general.error") +"', 'errorGrowl');";
 69  
                 }
 70  
             }
 71  
             
 72  0
             if(messageMap.hasWarnings()){
 73  0
                 String message = configService.getPropertyString("growl.hasWarnings");
 74  0
                 if(StringUtils.isNotBlank(message)){
 75  0
                     growlScript = growlScript + "showGrowl('" + message + "', '"+ configService.getPropertyString("general.warning") +"', 'warningGrowl');";
 76  
                 }
 77  
             }
 78  
             
 79  0
             if(messageMap.hasInfo()){
 80  0
                 List<String> properties = messageMap.getPropertiesWithInfo();
 81  0
                 String message = "";
 82  0
                 for(String property: properties){
 83  0
                     List<AutoPopulatingList<ErrorMessage>> lists = messageMap.getInfoMessagesForProperty(property, true);
 84  0
                     for (List<ErrorMessage> errorList : lists) {
 85  0
                         if (errorList != null) {
 86  0
                             for (ErrorMessage e : errorList) {
 87  0
                                 if(StringUtils.isBlank(message)){
 88  0
                                     message = configService.getPropertyString(e.getErrorKey());
 89  
                                 }
 90  
                                 else{
 91  0
                                     message = message + "<br/>" + configService.getPropertyString(e.getErrorKey());
 92  
                                 }
 93  0
                                 if (e.getMessageParameters() != null) {
 94  0
                                     message = message.replace("'", "''");
 95  0
                                     message = MessageFormat.format(message,
 96  
                                             (Object[]) e.getMessageParameters());
 97  
                                 }
 98  
                             }
 99  
                         }
 100  
                     }
 101  0
                 }
 102  
                 
 103  0
                 if(StringUtils.isNotBlank(message)){
 104  0
                     growlScript = growlScript + "showGrowl('" + message + "', '"+ configService.getPropertyString("general.info") +"', 'infoGrowl');";
 105  
                 }
 106  
             }
 107  
             
 108  
 
 109  
         }
 110  
         
 111  0
         this.setOnDocumentReadyScript(prefixScript + "\nsetupValidator();" + growlScript);
 112  0
     }
 113  
 
 114  
     /**
 115  
      * When this is true, the first field of the kualiForm will be focused by
 116  
      * default, unless the parameter focusId is set on the form (by an
 117  
      * actionField), then that field will be focused instead. When this setting
 118  
      * if false, no field will be focused.
 119  
      * 
 120  
      * @return the autoFocus
 121  
      */
 122  
     public boolean isAutoFocus() {
 123  0
         return this.autoFocus;
 124  
     }
 125  
 
 126  
     /**
 127  
      * @param autoFocus
 128  
      *            the autoFocus to set
 129  
      */
 130  
     public void setAutoFocus(boolean autoFocus) {
 131  0
         this.autoFocus = autoFocus;
 132  0
     }
 133  
 
 134  
 }