javax.faces.event.SystemEvent Java Examples

The following examples show how to use javax.faces.event.SystemEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdminSystemEventListener.java    From admin-template with MIT License 6 votes vote down vote up
public void processEvent(final SystemEvent event) {
    try {
        ResourceBundle adminBundle = ResourceBundle.getBundle("admin");
        ResourceBundle adminPersistenceBundle = null;
        try {
            adminPersistenceBundle = ResourceBundle.getBundle("admin-persistence");
        } catch (MissingResourceException mre) {
            //intentional
        }
        boolean isLegacyTemplate = has(adminBundle.getString("admin.legacy")) && adminBundle.getString("admin.legacy").equals("true");
        StringBuilder sb = new StringBuilder("Using Admin Template ")
                .append(adminBundle.getString("admin.version"))
                .append(isLegacyTemplate ? " (legacy)" : "");
        if (has(adminPersistenceBundle)) {
            sb.append(", Admin Persistence ").append(adminPersistenceBundle.getString("admin-persistence.version"));
        }
        sb.append(" and Admin Theme ").append(ResourceBundle.getBundle("admin-theme").getString("theme.version"));
        log.log(Level.INFO, sb.toString());
    } catch (Exception e) {
        log.log(Level.WARNING, "Could not get AdminFaces version.", e);
    }
}
 
Example #2
Source File: ViewScope.java    From joinfaces with Apache License 2.0 5 votes vote down vote up
@Override
public void processEvent(SystemEvent event) {
	UIViewRoot root = (UIViewRoot) event.getSource();
	root.getViewMap(false).values().stream()
			.filter(DestructionCallbackWrapper.class::isInstance)
			.map(DestructionCallbackWrapper.class::cast)
			.forEach(DestructionCallbackWrapper::onViewDestroy);
	getSessionListener().cleanup();
}
 
Example #3
Source File: AddResourcesListener.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
/**
 * Trigger adding the resources if and only if the event has been fired by
 * UIViewRoot.
 */
public void processEvent(SystemEvent event) throws AbortProcessingException {
	FacesContext context = FacesContext.getCurrentInstance();
	UIViewRoot root = context.getViewRoot();

	// render the resources only if there is at least one bsf component
	if (ensureExistBootsfacesComponent(root, context)) {
		addCSS(root, context);
		addJavascript(root, context);
		addMetaTags(root, context);
	}
}
 
Example #4
Source File: InjectionAwareApplicationWrapper.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Override
public void publishEvent(FacesContext facesContext, Class<? extends SystemEvent> systemEventClass, Object source)
{
    if (!PreDestroyViewMapEvent.class.isAssignableFrom(systemEventClass) ||
            isPreDestroyViewMapEventAllowed(facesContext))
    {
        super.publishEvent(facesContext, systemEventClass, source);
    }
}
 
Example #5
Source File: JsfSystemEventBroadcaster.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Override
public void processEvent(SystemEvent e) throws AbortProcessingException
{
    if (!this.isActivated)
    {
        return;
    }

    BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager();
    beanManager.fireEvent(e);
}
 
Example #6
Source File: BridgeExceptionHandlerWrapper.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException
{
    //handle exceptions which occur in a phase-listener (beforePhase) for PhaseId.RENDER_RESPONSE
    //needed because #handle gets called too late in this case
    if (event instanceof ExceptionQueuedEvent)
    {
        ExceptionQueuedEvent exceptionQueuedEvent = (ExceptionQueuedEvent)event;
        FacesContext facesContext = exceptionQueuedEvent.getContext().getContext();

        if (facesContext.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE &&
            exceptionQueuedEvent.getContext().inBeforePhase())
        {
            Throwable exception = getRootCause(exceptionQueuedEvent.getContext().getException());

            if (exception instanceof AccessDeniedException)
            {
                processAccessDeniedException(exception);
            }
            else
            {
                ExceptionToCatchEvent exceptionToCatchEvent = new ExceptionToCatchEvent(exception);
                exceptionToCatchEvent.setOptional(true);

                this.beanManager.fireEvent(exceptionToCatchEvent);

                if (exceptionToCatchEvent.isHandled())
                {
                    return;
                }
            }
        }
    }
    super.processEvent(event);
}
 
Example #7
Source File: ViewScopedContext.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
/**
 * We get PreDestroyViewMapEvent events from the JSF servlet and destroy our contextual
 * instances. This should (theoretically!) also get fired if the webapp closes, so there
 * should be no need to manually track all view scopes and destroy them at a shutdown.
 *
 * @see javax.faces.event.SystemEventListener#processEvent(javax.faces.event.SystemEvent)
 */
@Override
public void processEvent(SystemEvent event)
{
    if (event instanceof PreDestroyViewMapEvent)
    {
        destroyAllActive();
    }
}