View Javadoc
1   /**
2    * Copyright 2005-2014 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.util;
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.uif.component.Component;
21  import org.kuali.rice.krad.uif.element.ContentElementBase;
22  import org.kuali.rice.krad.uif.lifecycle.ViewLifecycle;
23  import org.kuali.rice.krad.uif.view.View;
24  
25  import java.util.HashMap;
26  import java.util.Map;
27  
28  /**
29   * BreadcrumbItem represents a single item in the breadcrumb list that is generated by the breadcrumbs widget.
30   *
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   */
33  @BeanTag(name = "breadcrumbItem-bean", parent = "Uif-BreadcrumbItem")
34  public class BreadcrumbItem extends ContentElementBase {
35      private static final long serialVersionUID = 6694853722827812544L;
36  
37      private String label;
38      private UrlInfo url;
39      private Component siblingBreadcrumbComponent;
40      private boolean renderAsLink;
41  
42      /**
43       * The following updates are done here:
44       *
45       * <ul>
46       * <li>Evaluate expressions on url object</li>
47       * </ul>
48       *
49       * {@inheritDoc}
50       */
51      @Override
52      public void performApplyModel(Object model, LifecycleElement parent) {
53          super.performApplyModel(model, parent);
54  
55          View view = ViewLifecycle.getView();
56          if (url != null) {
57              Map<String, Object> context = new HashMap<String, Object>();
58  
59              Map<String, Object> viewContext = view.getContext();
60              if (viewContext != null) {
61                  context.putAll(viewContext);
62              }
63  
64              ViewLifecycle.getExpressionEvaluator().populatePropertyExpressionsFromGraph(url, false);
65              ViewLifecycle.getExpressionEvaluator().evaluateExpressionsOnConfigurable(view, url, context);
66          }
67      }
68  
69      /**
70       * The label for this breadcrumbItem.  The label is the textual content that will be displayed for the breadcrumb.
71       *
72       * @return the label
73       */
74      @BeanTagAttribute(name = "label")
75      public String getLabel() {
76          return label;
77      }
78  
79      /**
80       * Set the label for this breadcrumbItem.  The label is the textual content that will be displayed for the
81       * breadcrumb.
82       *
83       * @param label
84       */
85      public void setLabel(String label) {
86          this.label = label;
87      }
88  
89      /**
90       * The url used for the breadcrumb link represented by this item
91       *
92       * @return the url object
93       */
94      @BeanTagAttribute(name = "url")
95      public UrlInfo getUrl() {
96          return url;
97      }
98  
99      /**
100      * Set the url object
101      *
102      * @param urlObject
103      */
104     public void setUrl(UrlInfo urlObject) {
105         this.url = urlObject;
106     }
107 
108     /**
109      * Set the breadcrumb component for this breadcrumbs sibling content/navigation.  This content will appear in
110      * a pop-up menu.
111      *
112      * @return the sibling component to appear in a popup menu
113      */
114     @BeanTagAttribute(name = "siblingBreadcrumbComponent", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
115     public Component getSiblingBreadcrumbComponent() {
116         return siblingBreadcrumbComponent;
117     }
118 
119     /**
120      * Set the sibling breadcrumb component
121      *
122      * @param siblingBreadcrumbComponent
123      */
124     public void setSiblingBreadcrumbComponent(Component siblingBreadcrumbComponent) {
125         this.siblingBreadcrumbComponent = siblingBreadcrumbComponent;
126     }
127 
128     /**
129      * If true, the breadcrumbItem will render as a link, otherwise it will render as a span (not-clickable).
130      * By default, the last BreadcrumbItem in the list will ALWAYS render as span regardless of this property's value.
131      *
132      * @return true if rendering as a link, false otherwise
133      */
134     @BeanTagAttribute(name = "renderAsLink")
135     public boolean isRenderAsLink() {
136         return renderAsLink;
137     }
138 
139     /**
140      * Set to true to render as a link, false otherwise
141      *
142      * @param renderAsLink
143      */
144     public void setRenderAsLink(boolean renderAsLink) {
145         this.renderAsLink = renderAsLink;
146     }
147 }