1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.labs.inquiry;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.kuali.rice.krad.inquiry.InquirableImpl;
22 import org.kuali.rice.krad.uif.component.Component;
23 import org.kuali.rice.krad.uif.container.Group;
24 import org.kuali.rice.krad.uif.container.PageGroup;
25 import org.kuali.rice.krad.uif.field.DataField;
26 import org.kuali.rice.krad.uif.util.ComponentFactory;
27 import org.kuali.rice.krad.uif.util.LifecycleElement;
28 import org.kuali.rice.krad.uif.view.InquiryView;
29
30
31
32
33
34
35 public class LabsInquiryDynamicSectionsInquirable extends InquirableImpl {
36
37 @Override
38 public void performCustomInitialization(LifecycleElement component) {
39 super.performCustomInitialization(component);
40
41 if (component instanceof InquiryView) {
42 InquiryView inquiryView = (InquiryView) component;
43 PageGroup pageGroup = inquiryView.getCurrentPage();
44
45 Group oldSection = (Group) pageGroup.getItems().get(0);
46 oldSection.setHeaderText(oldSection.getHeaderText() + " - Customized");
47
48 Group newSection = ComponentFactory.getGroupWithDisclosureGridLayout();
49 newSection.setHeaderText("Dynamically Added Section");
50 DataField newDataField = ComponentFactory.getDataField("newDataField", "Dynamically Added Field");
51 newDataField.setForcedValue("This is a dynamically set value.");
52
53 List<Component> fields = new ArrayList<Component>();
54 fields.add(newDataField);
55 newSection.setItems(fields);
56
57 List<Component> sections = new ArrayList<Component>();
58 sections.addAll(pageGroup.getItems());
59 sections.add(newSection);
60 pageGroup.setItems(sections);
61 }
62
63 }
64 }