3 Replies Latest reply on May 29, 2012 12:00 PM by Ken Finnigan

    Portlet Bridge 3.0 and JSF 2.0 and managed bean View scope

    reinanto54 Newbie


      I have experienced an issue with the portlet bridge 3.0 Beta and new scope "view".

      The managed bean is always instantiated during the restoreView phase. The managed bean saved in the new map viewMap available on the UIViewRoot is not properly restored.

      This is related to the clientId of the UIViewRoot (class PortletNamingContainerUIViewRoot).


      JSF 2 uses the view root client id to save/restore the state of UIViewRoot. During the saving (after the render phase), the client id of UIViewRoot is set to pb_xxxxx (the default id j_id1 is overridden by the method getContainerClientId called from the method UIComponent.getClientId()).

      public String getContainerClientId(FacesContext context)


              ExternalContext externalContext = context.getExternalContext();



                  String rootId = getId();

                  if(null == rootId || !rootId.startsWith("pb"))

                      setId(convertClientId(context, rootId));


              return super.getContainerClientId(context);



      However, during the restoreViewPhase, the state manager uses UIViewRoot.getClientId to get the state of the viewRoot.

      Class StateManagementStrategyImpl, method restoreView

      String cid = target.getClientId(context.getFacesContext());

      Object stateObj = state.get(cid);

      At this point, the getClientId() return the default id j_id1  therefore, the UIViewRoot state can not be restored properly!


      I am wondering why the UIViewRoot defined in portlet bridge 3.0 (PortletNamingContainerUIViewRoot) is different than the one defined in portlet bridge 2.1.0 (class UIPortletAjaxViewRoot)

      If I use UIPortletAjaxViewRoot instead of PortletNamingContainerUIViewRoot, I do not experience the issue anymore.


      To my opinion, the portlet bridge 3.0 should use UIPortletAjaxViewRoot (UIPortletAjaxViewRoot seems to be buggy)