Skip to content

Commit a9ef84a

Browse files
committed
Followup fixes to make ro run on core 3.x
1 parent 92411d1 commit a9ef84a

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

omod/src/main/java/org/openmrs/web/controller/LegacyCatchAllController.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ public class LegacyCatchAllController implements Controller {
4545
private Controller personFormEntryPortletController;
4646

4747
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
48-
String path = request.getRequestURI();
48+
// For included requests (e.g. pageContext.include()), use the include request URI
49+
String path = (String) request.getAttribute("jakarta.servlet.include.request_uri");
50+
if (path == null) {
51+
path = request.getRequestURI();
52+
}
4953
if (path == null) {
5054
response.sendError(HttpServletResponse.SC_NOT_FOUND);
5155
return null;
@@ -141,5 +145,4 @@ public void setPatientVisitsPortletController(Controller patientVisitsPortletCon
141145
public void setPersonFormEntryPortletController(Controller personFormEntryPortletController) {
142146
this.personFormEntryPortletController = personFormEntryPortletController;
143147
}
144-
}
145-
148+
}

omod/src/main/java/org/openmrs/web/taglib/PortletTag.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@
99
*/
1010
package org.openmrs.web.taglib;
1111

12-
import jakarta.servlet.jsp.tagext.BodyTagSupport;
12+
import java.io.IOException;
13+
import java.util.Map;
14+
1315
import org.apache.commons.logging.Log;
1416
import org.apache.commons.logging.LogFactory;
1517
import org.openmrs.module.Module;
1618
import org.openmrs.module.ModuleFactory;
1719
import org.openmrs.util.OpenmrsUtil;
1820

21+
import jakarta.servlet.ServletException;
1922
import jakarta.servlet.jsp.JspException;
2023
import jakarta.servlet.jsp.JspTagException;
2124
import jakarta.servlet.jsp.PageContext;
22-
import java.io.IOException;
23-
import java.util.Map;
25+
import jakarta.servlet.jsp.tagext.BodyTagSupport;
2426

2527
public class PortletTag extends BodyTagSupport {
2628

@@ -88,13 +90,17 @@ public int doStartTag() throws JspException {
8890
pageContext.getRequest().setAttribute("org.openmrs.portlet.userId", userId);
8991
pageContext.getRequest().setAttribute("org.openmrs.portlet.patientIds", patientIds);
9092
pageContext.getRequest().setAttribute("org.openmrs.portlet.parameterMap", parameterMap);
93+
94+
// include the portlet content
95+
pageContext.getOut().flush();
96+
pageContext.include(url);
9197
}
9298
}
93-
catch (IOException e) {
99+
catch (IOException | ServletException e) {
94100
log.error("Error while starting portlet tag", e);
95101
}
96102

97-
return super.doStartTag();
103+
return SKIP_BODY;
98104
}
99105

100106
public int doEndTag() throws JspException {
@@ -265,4 +271,4 @@ public void setModuleId(String moduleId) {
265271
public String getUrl() {
266272
return url;
267273
}
268-
}
274+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<%@ taglib prefix="openmrs" uri="/WEB-INF/view/module/legacyui/taglibs/openmrs.tld" %>
22
<%@ taglib prefix="openmrs_tag" tagdir="/WEB-INF/tags/module/legacyui" %>
3+
<%@ taglib prefix="fn" uri="jakarta.tags.functions" %>
34
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
45
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

0 commit comments

Comments
 (0)