1
2
3
4
5
6
7
8
9
10
11
12 package org.exoplatform.wcm.webui.search;
13
14 import javax.portlet.PortletMode;
15
16 import org.exoplatform.wcm.webui.search.config.UIPortletConfig;
17 import org.exoplatform.webui.application.WebuiApplication;
18 import org.exoplatform.webui.application.WebuiRequestContext;
19 import org.exoplatform.webui.application.portlet.PortletRequestContext;
20 import org.exoplatform.webui.config.annotation.ComponentConfig;
21 import org.exoplatform.webui.core.UIPopupContainer;
22 import org.exoplatform.webui.core.UIPortletApplication;
23 import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
24
25
26
27
28
29 @ComponentConfig(lifecycle = UIApplicationLifecycle.class)
30 public class UIWCMSearchPortlet extends UIPortletApplication {
31
32
33 private PortletMode mode = PortletMode.VIEW;
34
35
36 public static final String SEARCH_FORM_TEMPLATE_PATH = "searchFormTemplatePath";
37
38
39 public static final String SEARCH_RESULT_TEMPLATE_PATH = "searchResultTemplatePath";
40
41
42 public static final String SEARCH_PAGINATOR_TEMPLATE_PATH = "searchPaginatorTemplatePath";
43
44
45 public static final String SEARCH_PAGE_LAYOUT_TEMPLATE_PATH = "searchPageLayoutTemplatePath";
46
47
48 public static final String REPOSITORY = "repository";
49
50
51 public static final String WORKSPACE = "workspace";
52
53
54 public final static String ITEMS_PER_PAGE = "itemsPerPage";
55
56
57 public final static String PAGE_MODE = "pageMode";
58
59
60 public final static String BASE_PATH = "basePath";
61
62
63 public final static String DETAIL_PARAMETER_NAME = "detailParameterName";
64
65
66 public static final String SEARCH_PAGE_MODE = "Page";
67
68
69 public static final String SEARCH_CONTENT_MODE = "Document";
70
71
72
73
74
75
76
77
78 public UIWCMSearchPortlet() throws Exception {
79 activateMode(mode);
80
81 }
82
83
84
85
86
87
88
89
90 public void processRender(WebuiApplication app, WebuiRequestContext context) throws Exception {
91 PortletRequestContext pContext = (PortletRequestContext) context;
92 PortletMode newMode = pContext.getApplicationMode();
93 if (!mode.equals(newMode)) {
94 activateMode(newMode);
95 mode = newMode;
96 }
97 super.processRender(app, context);
98 }
99
100
101
102
103
104
105
106 private void activateMode(PortletMode mode) throws Exception {
107 getChildren().clear();
108 addChild(UIPopupContainer.class, null, "UISearchedContentEdittingPopup");
109 if (PortletMode.VIEW.equals(mode)) {
110 addChild(UISearchPageLayout.class, null, UIPortletApplication.VIEW_MODE);
111 } else if (PortletMode.EDIT.equals(mode)) {
112 addChild(UIPortletConfig.class, null, UIPortletApplication.EDIT_MODE);
113 }
114 }
115 }