@Override public void setId(String id) { if (BridgeUtil.isPortletRequest()) { if (namespace == null) { getContainerClientId(FacesContext.getCurrentInstance()); } id = namespace; } super.setId(id); }
/** * NamingContainer semantics worked generically (serviced by subclasses) as long as the class * is marked as implementing NamingContainer and we use the portletNamespace Id as * (part of) the component's id. */ @Override public String getContainerClientId(FacesContext context) { if (BridgeUtil.isPortletRequest()) { // Some impls (Facelets don't set an id on the UIViewRoot) -- Also handles the action case if ((this.getId() == null || !this.getId().startsWith(PORTLET_NAMESPACE_ID_PREFIX))) { setId(this.getId()); // setId can handle the null } return super.getContainerClientId(context); } else { return null; } }
/** * Create a new UIComponent subclass, using the mappings defined by previous * calls to the addComponent method of this class. * <p> * @throws FacesException if there is no mapping defined for the specified * componentType, or if an instance of the specified type could not be * created for any reason. */ public javax.faces.component.UIComponent createComponent(String componentType) throws FacesException { UIComponent component = mWrapped.createComponent(componentType); if (BridgeUtil.isPortletRequest() && component.getClass() == UIViewRoot.class && UIViewRoot.class.getAnnotation(PortletNamingContainer.class) == null ) { // replace with our own UIViewRoot component = new PortletNamingContainerUIViewRoot(); } return component; }
/** * <p>This method fixes a problem with {@link UIComponent#findComponent(String)} where sometimes it is unable to * find components due to incorrect clientId values. For more info, see the following issues: * * <ul> * <li>http://issues.liferay.com/browse/FACES-198</li> * <li>http://jira.icesoft.org/browse/ICE-6659</li> * <li>http://jira.icesoft.org/browse/ICE-6667</li> * </ul> * </p> */ @Override public void setId(String id) { if (BridgeUtil.isPortletRequest()) { super.setId(getContainerClientId(FacesContext.getCurrentInstance())); } }
List<UIComponent> uiViewRootComponentResources = uiViewRoot.getComponentResources(facesContext, "head"); List<UIComponent> uiViewRootStyleSheetResources = null; List<UIComponent> uiViewRootScriptResources = null; uiViewRoot.addComponentResource(facesContext, uiComponentResource, "body");
@Override public void setId(String id) { 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 a uniqueId if (id == null) { id = createUniqueId(); } // 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 // set is using the already encoded (saved) value we could end up with a doubly // encoded id until the restore overwrites. To avoid this -- first test if // its already encoded and don't re-encode. if (!id.startsWith(PORTLET_NAMESPACE_ID_PREFIX)) { ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext(); id = PORTLET_NAMESPACE_ID_PREFIX + ec.encodeNamespace("") + "_" + id; } } super.setId(id); }
/** * <p>This method fixes a problem with {@link UIComponent#findComponent(String)} where sometimes it is unable to * find components due to incorrect clientId values. For more info, see the following issues: * * <ul> * <li>http://issues.liferay.com/browse/FACES-198</li> * <li>http://jira.icesoft.org/browse/ICE-6659</li> * <li>http://jira.icesoft.org/browse/ICE-6667</li> * </ul> * </p> */ @Override public void setId(String id) { if (BridgeUtil.isPortletRequest()) { super.setId(getContainerClientId(FacesContext.getCurrentInstance())); } }
List<UIComponent> uiViewRootComponentResources = uiViewRoot.getComponentResources(facesContext, "head"); List<UIComponent> uiViewRootStyleSheetResources = null; List<UIComponent> uiViewRootScriptResources = null; uiViewRoot.addComponentResource(facesContext, uiComponentResource, "body");
String id = viewRoot.getContainerClientId(facesContext); responseWriter.writeAttribute("id", id, null);
String id = viewRoot.getContainerClientId(facesContext); responseWriter.writeAttribute("id", id, null);