{
final IRequestablePage page = getPage();
final boolean freshPage = pageComponentProvider.isPageInstanceFresh();
final boolean isAjax = ((WebRequest)requestCycle.getRequest()).isAjax();
IRequestableComponent component;
try
{
component = getComponent();
}
catch (ComponentNotFoundException e)
{
// either the page is stateless and the component we are looking for is not added in the
// constructor
// or the page is stateful+stale and a new instances was created by pageprovider
// we denote this by setting component to null
component = null;
}
if ((component == null && !freshPage) || (component != null && component.getPage() != page))
{
throw new ComponentNotFoundException("Component '" + getComponentPath()
+ "' has been removed from page.");
}
if (page instanceof Page)
{
// initialize the page to be able to check whether it is stateless
((Page)page).internalInitialize();
}
final boolean isStateless = page.isPageStateless();
RedirectPolicy policy = isStateless
? RedirectPolicy.NEVER_REDIRECT
: RedirectPolicy.AUTO_REDIRECT;
final IPageProvider pageProvider = new PageProvider(page);
final boolean canCallListenerInterfaceAfterExpiry = component != null
? component.canCallListenerInterfaceAfterExpiry()
: false;
if (!canCallListenerInterfaceAfterExpiry && freshPage && (isStateless == false || component == null))
{
// A listener interface is invoked on an expired page.