001    /**
002     * Copyright 2005-2014 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.krad.uif.util;
017    
018    import org.kuali.rice.krad.datadictionary.parse.BeanTag;
019    import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
020    
021    /**
022     * KeyValue that has an additional location property that takes a Url object.  When this is used with a dropdown or
023     * an optionList control, those options become navigation controls.
024     *
025     * @author Kuali Rice Team (rice.collab@kuali.org)
026     */
027    @BeanTag(name = "keyValueLocation-bean", parent = "Uif-KeyValueLocation")
028    public class UifKeyValueLocation extends UifKeyValue {
029        private static final long serialVersionUID = -4613047498920929280L;
030    
031        private UrlInfo location;
032    
033        /**
034         * Base constructor
035         */
036        public UifKeyValueLocation() {
037            super();
038        }
039    
040        public UifKeyValueLocation(String key, String value) {
041            super(key, value);
042        }
043    
044        /**
045         * KeyValueLocation constructor
046         *
047         * @param key the key
048         * @param value the value
049         * @param location the url location object
050         */
051        public UifKeyValueLocation(String key, String value, UrlInfo location) {
052            this.key = key;
053            this.value = value;
054            this.location = location;
055        }
056    
057        /**
058         * Get the url object representing the location
059         *
060         * @return the url location object
061         */
062        @BeanTagAttribute(name = "location", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
063        public UrlInfo getLocation() {
064            return location;
065        }
066    
067        /**
068         * Set the url location object
069         *
070         * @param location
071         */
072        public void setLocation(UrlInfo location) {
073            this.location = location;
074        }
075    
076        /**
077         * Convenience setter for setting the href (full URL) of the location object
078         *
079         * @param href URL for location option
080         */
081        public void setHref(String href) {
082            if (this.location == null) {
083                this.location = ComponentFactory.getUrlInfo();
084            }
085    
086            this.location.setHref(href);
087        }
088    
089    }