Fix NPE issue with JSF/Portlet support
This commit is contained in:
@@ -308,11 +308,18 @@ public class PortletExternalContextImpl extends ExternalContext {
|
||||
|
||||
@Override
|
||||
public String getRequestCharacterEncoding() {
|
||||
return getActionRequest().getCharacterEncoding();
|
||||
if (request instanceof ClientDataRequest) {
|
||||
return ((ClientDataRequest) request).getCharacterEncoding();
|
||||
}
|
||||
else {
|
||||
Assert.state(response instanceof MimeResponse);
|
||||
return ((MimeResponse) response).getCharacterEncoding();
|
||||
}
|
||||
}
|
||||
|
||||
public void setRequestCharacterEncoding(String encoding) throws java.io.UnsupportedEncodingException {
|
||||
getActionRequest().setCharacterEncoding(encoding);
|
||||
Assert.isInstanceOf(ClientDataRequest.class, request);
|
||||
((ClientDataRequest) request).setCharacterEncoding(encoding);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -365,11 +372,6 @@ public class PortletExternalContextImpl extends ExternalContext {
|
||||
return requestParameterValuesMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestPathInfo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestServletPath() {
|
||||
// Return "" instead of null in order to prevent NullPointerException in Apache MyFaces 1.2 when it tries to
|
||||
@@ -379,7 +381,13 @@ public class PortletExternalContextImpl extends ExternalContext {
|
||||
// Alternatively this method could be implemented to provide an actual servlet path derived from the
|
||||
// viewId when that becomes available during rendering as the MyFaces Portlet Bridge does.
|
||||
//
|
||||
return (JsfRuntimeInformation.isMyFacesPresent()) ? "" : null;
|
||||
// return JsfRuntimeInformation.isMyFacesPresent() ? "" : null;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestPathInfo() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public int getRequestContentLength() {
|
||||
@@ -387,11 +395,6 @@ public class PortletExternalContextImpl extends ExternalContext {
|
||||
return ((ClientDataRequest) request).getContentLength();
|
||||
}
|
||||
|
||||
private ActionRequest getActionRequest() {
|
||||
Assert.isInstanceOf(ActionRequest.class, request);
|
||||
return (ActionRequest) request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthType() {
|
||||
return request.getAuthType();
|
||||
|
||||
@@ -61,7 +61,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* implementation provides an alternative that accepts Portlet request and response structures and creates a
|
||||
* {@link PortletExternalContextImpl} in its constructor. The rest of the method implementations mimic the equivalent
|
||||
* methods in the default FacesContext implementation.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Phillip Webb
|
||||
* @since 2.2.0
|
||||
@@ -119,8 +119,9 @@ public class PortletFacesContextImpl extends FacesContext {
|
||||
application = JsfUtils.findFactory(ApplicationFactory.class).getApplication();
|
||||
renderKitFactory = JsfUtils.findFactory(RenderKitFactory.class);
|
||||
this.externalContext = new PortletExternalContextImpl(portletContext, portletRequest, portletResponse);
|
||||
this.exceptionHandler = JsfUtils.findFactory(ExceptionHandlerFactory.class).getExceptionHandler();
|
||||
FacesContext.setCurrentInstance(this);
|
||||
// This depends on the current FacesContext instance
|
||||
this.exceptionHandler = JsfUtils.findFactory(ExceptionHandlerFactory.class).getExceptionHandler();
|
||||
}
|
||||
|
||||
public void release() {
|
||||
|
||||
Reference in New Issue
Block a user