Coverage Report - org.kuali.rice.kns.uif.widget.LightBoxLookup
 
Classes in this File Line Coverage Branch Coverage Complexity
LightBoxLookup
0%
0/21
0%
0/18
3.25
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 1.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/ecl1.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.kns.uif.widget;
 17  
 
 18  
 import java.util.HashMap;
 19  
 
 20  
 import org.apache.commons.lang.StringUtils;
 21  
 
 22  
 /**
 23  
  * Used for rendering a lightbox in the UI to display links in dialog popups
 24  
  * 
 25  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 26  
  */
 27  
 public class LightBoxLookup extends WidgetBase {
 28  
         private static final long serialVersionUID = -8571541274489677888L;
 29  
         
 30  
     private String actionParameterMapString;
 31  
         
 32  
         public LightBoxLookup() {
 33  0
                 super();
 34  0
         }
 35  
 
 36  
         /**
 37  
          * Overide to cater for passing functions to fancybox without quotes.
 38  
          * If this is not be specific to Fancybox it should be moved to ComponentBase
 39  
          * Builds a string from the underlying <code>Map</code> of component options
 40  
          * that will export that options as a JavaScript Map for use in js and
 41  
          * jQuery plugins. 
 42  
          * 
 43  
          * @return String of widget options formatted as JS Map
 44  
          */
 45  
         @Override
 46  
         public String getComponentOptionsJSString() {
 47  0
                 if (getComponentOptions() == null) {
 48  0
                         setComponentOptions(new HashMap<String, String>());
 49  
                 }
 50  0
                 StringBuffer sb = new StringBuffer();
 51  
 
 52  0
                 sb.append("{");
 53  
 
 54  0
                 for (String optionKey : getComponentOptions().keySet()) {
 55  0
                         String optionValue = getComponentOptions().get(optionKey);
 56  
 
 57  0
                         if (sb.length() > 1) {
 58  0
                                 sb.append(",");
 59  
                         }
 60  
 
 61  0
                         sb.append(optionKey);
 62  0
                         sb.append(":");
 63  
 
 64  
                         //If an option value starts with { or [, it would be a nested value and it should not use quotes around it
 65  
                         // If value is a function script do not use quotes
 66  0
                         if (StringUtils.startsWith(optionValue, "{") || StringUtils.startsWith(optionValue, "[") 
 67  
                                         || (StringUtils.startsWith(optionValue, "function") && StringUtils.endsWith(optionValue, "}")) 
 68  
                                         ||  optionValue.equals("true") || optionValue.equals("false")){
 69  0
                                 sb.append(optionValue);
 70  
                         }else{
 71  0
                                 sb.append("\"" + optionValue + "\"");
 72  
                         }
 73  0
                 }
 74  
 
 75  0
                 sb.append("}");
 76  0
                 return sb.toString();
 77  
         }
 78  
 
 79  
         /**
 80  
          * @param dataObjectClassName the dataObjectClassName to set
 81  
          */
 82  
         public void setActionParameterMapString(String actionParameterMapString) {
 83  0
                 this.actionParameterMapString = actionParameterMapString;
 84  0
         }
 85  
 
 86  
         /**
 87  
          * @return the dataObjectClassName
 88  
          */
 89  
         public String getActionParameterMapString() {
 90  0
                 return actionParameterMapString;
 91  
         }        
 92  
         
 93  
 }