You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mf...@apache.org on 2010/02/19 23:33:09 UTC
svn commit: r912019 - in
/myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces:
BridgeUtil.java component/PortletNamingContainerUIViewRoot.java
Author: mfreedman
Date: Fri Feb 19 22:33:09 2010
New Revision: 912019
URL: http://svn.apache.org/viewvc?rev=912019&view=rev
Log:
PORTLETBRIDGE-123: PortletNamingContainerUIViewRoot throws NullPointerException
PORTLETBRIDGE-122: BridgeUtil.isPortletRequest throws NullPointerException
Modified:
myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/BridgeUtil.java
myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/BridgeUtil.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/BridgeUtil.java?rev=912019&r1=912018&r2=912019&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/BridgeUtil.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/BridgeUtil.java Fri Feb 19 22:33:09 2010
@@ -29,7 +29,14 @@
*/
public static boolean isPortletRequest()
{
- Map<String, Object> m = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
+ FacesContext ctx = FacesContext.getCurrentInstance();
+
+ // This method might be called during App startup (via a context listener) and hence no FacesContext
+ // For example a renderkit might createComponents during such time -- as the bridge overrides faces Application
+ // which implements createComponent and calls this method (to see if we need to wrap/replace with the NamingContainer
+ if (ctx == null) return false;
+
+ Map<String, Object> m = ctx.getExternalContext().getRequestMap();
Bridge.PortletPhase phase = (Bridge.PortletPhase) m.get(Bridge.PORTLET_LIFECYCLE_PHASE);
if (phase != null)
{
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java?rev=912019&r1=912018&r2=912019&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java Fri Feb 19 22:33:09 2010
@@ -54,8 +54,13 @@
@Override
public String getContainerClientId(FacesContext context)
{
- if (BridgeUtil.isPortletRequest() && ((Boolean) this.getAttributes().get(PORTLET_ENCODED_NAMESPACE_ID)).equals(Boolean.TRUE))
+ if (BridgeUtil.isPortletRequest())
{
+ // Some impls (Facelets don't set an id on the UIViewRoot) -- so do so now
+ if (((Boolean) this.getAttributes().get(PORTLET_ENCODED_NAMESPACE_ID)).equals(Boolean.FALSE))
+ {
+ setId(null); // setId has a default for this
+ }
return super.getContainerClientId(context);
}
else
@@ -70,6 +75,13 @@
{
if (BridgeUtil.isPortletRequest())
{
+ // Turns out that in Facelets the UIViewRoot doesn't seem to have its id set -- i.e. its null
+ // So recognize null and change to ""
+ if (id == null)
+ {
+ id = "";
+ }
+
// Turns out some Faces impls (the RI) , on restoreView, manually sets the id from
// the extracted state prior to telling the component to restore itself from this state.
// (At which point the self restore overwrites any id set prior.). As this manual