public void preRenderPage()

in empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/Page.java [133:214]


    public void preRenderPage(FacesContext context)
    {
        // Check initialized
        if (initialized>0)
        {   try
            {   // refresh
                if (log.isDebugEnabled())
                    log.debug("PageBean {} is already initialized. Calling doRefresh().", getPageName());
                doRefresh();
            }
            catch (Exception e)
            {
                logAndHandleActionException("doRefresh", e);
            }
            return; // already Initialized
        }

        // Check pending
        if (initialized==0)
        {   // Initialization pending
            Exception e = new InvalidOperationException("Page Initialization pending.");
            WebApplication.getInstance().handleException(context, this, e);
        }
        // Initialization pending
        initialized=0;
        
        // Check access
        try
        {
            checkPageAccess();
            // redirected?
            if (context.getResponseComplete())
                return;
        }
        catch (Exception e)
        {
            logAndHandleActionException("checkAccess", e);
            // redirected?
            if (context.getResponseComplete())
                return;
            // Oops, not redirected yet?
            if (getParentPage()!=null)
                navigateTo(getParentOutcome(true)); 
            // Done
            return;
        }

        // String value of "null"?
        if (this.action!=null && "null".equals(this.action))
        {   log.warn("Invalid action name 'null' for {}", getClass().getName());
            this.action = null;
        }    
        
        // Execute Action
        if (this.action!=null && this.action.length()>0)
        {   // process action
            try
            {   log.debug("Processing action {} on page {}.", action, getPageName());
                executeAction(action, context);
            } finally {
                // Clear action
                this.action = null;
            }
        }
        else
        {   // call default Action
            try
            {   log.debug("Initializing page {} using doInit()", getPageName());
                doInit();
                // if not redirected, restore SessionMessage
                if (!context.getResponseComplete())
                    restoreSessionMessage();
            }
            catch (Exception e)
            {
                logAndHandleActionException("doInit", e);
            }
        }
        
        // Initialized unless redirected
        this.initialized = (context.getResponseComplete() ? (short)-1 : 1);
    }