Skip to content

Commit 2f6d7b6

Browse files
committed
introduce PageConfig method to get the history attribute name
1 parent d9c55de commit 2f6d7b6

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

opengrok-web/src/main/java/org/opengrok/web/PageConfig.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public final class PageConfig {
118118

119119
public static final String DUMMY_REVISION = "unknown";
120120

121-
public static final String HISTORY_JSP_ATTR_NAME = "history.jsp-hist";
121+
private static final String HISTORY_JSP_ATTR_NAME = "history.jsp-hist";
122122

123123
// query parameters
124124
static final String PROJECT_PARAM_NAME = "project";
@@ -183,6 +183,13 @@ public Object getRequestAttribute(String attr) {
183183
return this.req.getAttribute(attr);
184184
}
185185

186+
/**
187+
* @return name of the JSP attribute to store the {@link org.opengrok.indexer.history.History} object.
188+
*/
189+
public String getHistoryAttrName() {
190+
return HISTORY_JSP_ATTR_NAME;
191+
}
192+
186193
/**
187194
* Removes an attribute from the current request.
188195
* @param string the attribute

opengrok-web/src/main/webapp/history.jsp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ org.opengrok.indexer.web.Util"
9898
response.sendError(HttpServletResponse.SC_NOT_FOUND);
9999
return;
100100
}
101-
request.setAttribute(PageConfig.HISTORY_JSP_ATTR_NAME, hist);
101+
request.setAttribute(cfg.getHistoryAttrName(), hist);
102102
}
103103
}
104104
%>
@@ -109,7 +109,8 @@ include file="/httpheader.jspf"
109109
%>
110110
<%
111111
{
112-
if ((request.getAttribute(PageConfig.HISTORY_JSP_ATTR_NAME)) != null) {
112+
PageConfig cfg = PageConfig.get(request);
113+
if ((request.getAttribute(cfg.getHistoryAttrName())) != null) {
113114
%>
114115
<body>
115116
<script type="text/javascript">/* <![CDATA[ */
@@ -124,7 +125,8 @@ include file="/httpheader.jspf"
124125
}
125126
}
126127
{
127-
if (request.getAttribute(PageConfig.HISTORY_JSP_ATTR_NAME) != null) {
128+
PageConfig cfg = PageConfig.get(request);
129+
if (request.getAttribute(cfg.getHistoryAttrName()) != null) {
128130
%>
129131
<%@include file="/pageheader.jspf" %>
130132
<%
@@ -136,7 +138,7 @@ include file="/httpheader.jspf"
136138
String path = cfg.getPath();
137139
138140
History hist;
139-
if ((hist = (History) request.getAttribute(PageConfig.HISTORY_JSP_ATTR_NAME)) != null) {
141+
if ((hist = (History) request.getAttribute(cfg.getHistoryAttrName())) != null) {
140142
141143
int startIndex = cfg.getStartIndex();
142144
int max = cfg.getMaxItems();
@@ -155,7 +157,8 @@ include file="/httpheader.jspf"
155157
}
156158
}
157159
{
158-
if (request.getAttribute(PageConfig.HISTORY_JSP_ATTR_NAME) != null) {
160+
PageConfig cfg = PageConfig.get(request);
161+
if (request.getAttribute(cfg.getHistoryAttrName()) != null) {
159162
%>
160163
<%@
161164
@@ -170,7 +173,8 @@ include file="/minisearch.jspf"
170173
String context = request.getContextPath();
171174
String path = cfg.getPath();
172175
History hist;
173-
if ((hist = (History) request.getAttribute(PageConfig.HISTORY_JSP_ATTR_NAME)) != null) {
176+
177+
if ((hist = (History) request.getAttribute(cfg.getHistoryAttrName())) != null) {
174178
RuntimeEnvironment env = cfg.getEnv();
175179
String uriEncodedName = cfg.getUriEncodedPath();
176180
Project project = cfg.getProject();

0 commit comments

Comments
 (0)