Details
-
Type: Improvement
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.8.1
-
Component/s: ICE-Components
-
Labels:None
-
Environment:portlets dataexporter
-
ICEsoft Forum Reference:
-
Affects:Compatibility/Configuration
Description
In the DataExporter.createFile method, the following logic is used:
ServletContext context = ((HttpSession) FacesContext
.getCurrentInstance().getExternalContext().getSession(false))
.getServletContext();
Casting to an HttpSession and attempting to retrieve the ServletContext will not work in portlets. In this case, the context is used to access the getRealPath() API to determine the location in the filesystem for storing/reading documents. The Portlet API also makes this available via the PortletContext. The code would need to look something like this:
PortletContext pContext = ((PortletSession) FacesContext
.getCurrentInstance().getExternalContext().getSession(false))
.getPortletContext();
There is no JSF way to do this that will work in both environments unfortunately so we'll need to ensure that this is done in a way that doesn't require a runtime dependency on the portlet.jar as it will not be available in plain web-apps.
ServletContext context = ((HttpSession) FacesContext
.getCurrentInstance().getExternalContext().getSession(false))
.getServletContext();
Casting to an HttpSession and attempting to retrieve the ServletContext will not work in portlets. In this case, the context is used to access the getRealPath() API to determine the location in the filesystem for storing/reading documents. The Portlet API also makes this available via the PortletContext. The code would need to look something like this:
PortletContext pContext = ((PortletSession) FacesContext
.getCurrentInstance().getExternalContext().getSession(false))
.getPortletContext();
There is no JSF way to do this that will work in both environments unfortunately so we'll need to ensure that this is done in a way that doesn't require a runtime dependency on the portlet.jar as it will not be available in plain web-apps.
Issue Links
- blocks
-
ICE-4367 dataExporter does not work in portal environment
- Closed
Please correct, you'll need to implement using reflection to avoid runtime dependencies on portlet APIs in a none-portlet environment.