1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.util;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
20 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
21 import org.kuali.rice.krad.uif.container.Container;
22 import org.kuali.rice.krad.uif.view.View;
23 import org.kuali.rice.krad.web.form.UifFormBase;
24
25 import java.util.Map;
26
27
28
29
30 @BeanTag(name = "pageBreadcrumbOptions-bean", parent = "Uif-PageBreadcrumbOptions")
31 public class PageBreadcrumbOptions extends BreadcrumbOptions {
32 private static final long serialVersionUID = -5666730356781875858L;
33
34
35 private boolean renderViewBreadcrumb;
36 private boolean renderHomewardPathBreadcrumbs;
37 private boolean renderPreViewBreadcrumbs;
38 private boolean renderPrePageBreadcrumbs;
39 private boolean renderParentLocations;
40
41
42
43
44
45
46
47 @Override
48 public void setupBreadcrumbs(View view, Object model) {
49 BreadcrumbOptions viewBreadcrumbOptions = view.getBreadcrumbOptions();
50
51
52 if (this.getHomewardPathBreadcrumbs() == null
53 && viewBreadcrumbOptions != null
54 && viewBreadcrumbOptions.getHomewardPathBreadcrumbs() != null) {
55 this.setHomewardPathBreadcrumbs(viewBreadcrumbOptions.getHomewardPathBreadcrumbs());
56
57 for (BreadcrumbItem item : this.getHomewardPathBreadcrumbs()) {
58 view.assignComponentIds(item);
59 }
60 }
61
62 if (this.getPrePageBreadcrumbs() == null
63 && viewBreadcrumbOptions != null
64 && viewBreadcrumbOptions.getPrePageBreadcrumbs() != null) {
65 this.setPrePageBreadcrumbs(viewBreadcrumbOptions.getPrePageBreadcrumbs());
66
67 for (BreadcrumbItem item : this.getPrePageBreadcrumbs()) {
68 view.assignComponentIds(item);
69 }
70 }
71
72 if (this.getPreViewBreadcrumbs() == null
73 && viewBreadcrumbOptions != null
74 && viewBreadcrumbOptions.getPreViewBreadcrumbs() != null) {
75 this.setPreViewBreadcrumbs(viewBreadcrumbOptions.getPreViewBreadcrumbs());
76
77 for (BreadcrumbItem item : this.getPreViewBreadcrumbs()) {
78 view.assignComponentIds(item);
79 }
80 }
81
82 if (this.getBreadcrumbOverrides() == null
83 && viewBreadcrumbOptions != null
84 && viewBreadcrumbOptions.getBreadcrumbOverrides() != null) {
85 this.setBreadcrumbOverrides(viewBreadcrumbOptions.getBreadcrumbOverrides());
86
87 for (BreadcrumbItem item : this.getBreadcrumbOverrides()) {
88 view.assignComponentIds(item);
89 }
90 }
91 }
92
93
94
95
96
97
98
99
100 @Override
101 public void finalizeBreadcrumbs(View view, Object model, Container parent, BreadcrumbItem breadcrumbItem) {
102
103 if (StringUtils.isBlank(breadcrumbItem.getLabel()) && parent.getHeader() != null && StringUtils.isNotBlank(
104 parent.getHeader().getHeaderText())) {
105 breadcrumbItem.setLabel(parent.getHeader().getHeaderText());
106 }
107
108
109 if (StringUtils.isBlank(breadcrumbItem.getLabel())) {
110 breadcrumbItem.setRender(false);
111 }
112
113
114 if (breadcrumbItem.getUrl().getControllerMapping() == null
115 && breadcrumbItem.getUrl().getViewId() == null
116 && model instanceof UifFormBase
117 && breadcrumbItem.getUrl().getRequestParameters() == null
118 && ((UifFormBase) model).getInitialRequestParameters() != null) {
119
120
121 Map<String, String> requestParameters = ((UifFormBase) model).getInitialRequestParameters();
122
123
124 requestParameters.remove("ajaxReturnType");
125 requestParameters.remove("ajaxRequest");
126
127
128 requestParameters.remove("pageId");
129
130 breadcrumbItem.getUrl().setRequestParameters(requestParameters);
131 }
132
133
134 if (breadcrumbItem.getUrl().getFormKey() == null
135 && model instanceof UifFormBase
136 && ((UifFormBase) model).getFormKey() != null) {
137 breadcrumbItem.getUrl().setFormKey(((UifFormBase) model).getFormKey());
138 }
139
140
141 if (breadcrumbItem.getUrl().getControllerMapping() == null && model instanceof UifFormBase) {
142 breadcrumbItem.getUrl().setControllerMapping(((UifFormBase) model).getControllerMapping());
143 }
144
145 if (breadcrumbItem.getUrl().getViewId() == null) {
146 breadcrumbItem.getUrl().setViewId(view.getId());
147 }
148
149 if (breadcrumbItem.getUrl().getPageId() == null) {
150 breadcrumbItem.getUrl().setPageId(parent.getId());
151 }
152 }
153
154
155
156
157
158
159 @BeanTagAttribute(name = "renderViewBreadcrumb")
160 public boolean isRenderViewBreadcrumb() {
161 return renderViewBreadcrumb;
162 }
163
164
165
166
167
168
169 public void setRenderViewBreadcrumb(boolean renderViewBreadcrumb) {
170 this.renderViewBreadcrumb = renderViewBreadcrumb;
171 }
172
173
174
175
176
177
178 @BeanTagAttribute(name = "renderHomewardPathBreadcrumbs")
179 public boolean isRenderHomewardPathBreadcrumbs() {
180 return renderHomewardPathBreadcrumbs;
181 }
182
183
184
185
186
187
188 public void setRenderHomewardPathBreadcrumbs(boolean renderHomewardPathBreadcrumbs) {
189 this.renderHomewardPathBreadcrumbs = renderHomewardPathBreadcrumbs;
190 }
191
192
193
194
195
196
197 @BeanTagAttribute(name = "renderPreViewBreadcrumbs")
198 public boolean isRenderPreViewBreadcrumbs() {
199 return renderPreViewBreadcrumbs;
200 }
201
202
203
204
205
206
207 public void setRenderPreViewBreadcrumbs(boolean renderPreViewBreadcrumbs) {
208 this.renderPreViewBreadcrumbs = renderPreViewBreadcrumbs;
209 }
210
211
212
213
214
215
216 @BeanTagAttribute(name = "renderPrePageBreadcrumbs")
217 public boolean isRenderPrePageBreadcrumbs() {
218 return renderPrePageBreadcrumbs;
219 }
220
221
222
223
224
225
226 public void setRenderPrePageBreadcrumbs(boolean renderPrePageBreadcrumbs) {
227 this.renderPrePageBreadcrumbs = renderPrePageBreadcrumbs;
228 }
229
230
231
232
233
234
235
236 @BeanTagAttribute(name = "renderParentLocations")
237 public boolean isRenderParentLocations() {
238 return renderParentLocations;
239 }
240
241
242
243
244
245
246 public void setRenderParentLocations(boolean renderParentLocations) {
247 this.renderParentLocations = renderParentLocations;
248 }
249
250
251
252
253
254
255 protected <T> void copyProperties(T breadcrumbOptions) {
256 super.copyProperties(breadcrumbOptions);
257 PageBreadcrumbOptions breadcrumbOptionsCopy = (PageBreadcrumbOptions) breadcrumbOptions;
258
259 breadcrumbOptionsCopy.setRenderViewBreadcrumb(this.renderViewBreadcrumb);
260 breadcrumbOptionsCopy.setRenderHomewardPathBreadcrumbs(this.renderHomewardPathBreadcrumbs);
261 breadcrumbOptionsCopy.setRenderPreViewBreadcrumbs(this.renderPreViewBreadcrumbs);
262 breadcrumbOptionsCopy.setRenderPrePageBreadcrumbs(this.renderPrePageBreadcrumbs);
263 breadcrumbOptionsCopy.setRenderParentLocations(this.renderParentLocations);
264 }
265 }