Search in sources :

Example 1 with UIViewRootBridgeImpl

use of com.liferay.faces.bridge.component.internal.UIViewRootBridgeImpl in project liferay-faces-bridge-impl by liferay.

the class ApplicationImpl method createComponent.

/**
 * This method provides the ability to supply an instance of the bridge API's {@link
 * PortletNamingContainerUIViewRoot} class which properly handles namespacing of "id" attributes for portlets.
 *
 * @see  Application#createComponent(String)
 */
@Override
@SuppressWarnings("unchecked")
public UIComponent createComponent(String componentType) throws FacesException {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    if (componentType.equals(UIViewRoot.COMPONENT_TYPE) && BridgeUtil.isPortletRequest(facesContext)) {
        // to cleanup @ViewScoped managed-beans.
        if (subscribeToEventsAtRuntime) {
            // order to ensure that it only happens once.
            synchronized (subscribeToEventsAtRuntime) {
                // Need to check again within the synchronization block, just in case.
                if (subscribeToEventsAtRuntime) {
                    BridgeConfig bridgeConfig = RequestMapUtil.getBridgeConfig(facesContext);
                    List<ConfiguredSystemEventListener> configuredSystemEventListeners = (List<ConfiguredSystemEventListener>) bridgeConfig.getAttributes().get(BridgeConfigAttributeMap.CONFIGURED_SYSTEM_EVENT_LISTENERS);
                    if (configuredSystemEventListeners != null) {
                        for (ConfiguredSystemEventListener configuredSystemEventListener : configuredSystemEventListeners) {
                            if (UIVIEWROOT_FQCN.equals(configuredSystemEventListener.getSourceClass())) {
                                subscribeToJSF2SystemEvent(configuredSystemEventListener);
                            }
                        }
                    }
                }
                subscribeToEventsAtRuntime = false;
            }
        }
        return new UIViewRootBridgeImpl();
    } else {
        return getWrapped().createComponent(componentType);
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) UIViewRootBridgeImpl(com.liferay.faces.bridge.component.internal.UIViewRootBridgeImpl) BridgeConfig(javax.portlet.faces.BridgeConfig) List(java.util.List) ConfiguredSystemEventListener(com.liferay.faces.util.config.ConfiguredSystemEventListener)

Aggregations

UIViewRootBridgeImpl (com.liferay.faces.bridge.component.internal.UIViewRootBridgeImpl)1 ConfiguredSystemEventListener (com.liferay.faces.util.config.ConfiguredSystemEventListener)1 List (java.util.List)1 FacesContext (javax.faces.context.FacesContext)1 BridgeConfig (javax.portlet.faces.BridgeConfig)1