//If no viewId found, don't try to derive it, just continue.
if (viewId == null)
{
return null;
}
FacesServletMapping mapping = getFacesServletMapping(context);
if (mapping == null || mapping.isExtensionMapping())
{
viewId = handleSuffixMapping(context, viewId);
}
else if(mapping.isPrefixMapping())
{
viewId = handlePrefixMapping(viewId,mapping.getPrefix());
// A viewId that is equals to the prefix mapping on servlet mode is
// considered invalid, because jsp vdl will use RequestDispatcher and cause
// a loop that ends in a exception. Note in portlet mode the view
// could be encoded as a query param, so the viewId could be valid.
if (viewId != null && viewId.equals(mapping.getPrefix()) &&
!ExternalContextUtils.isPortlet(context.getExternalContext()))
{
throw new InvalidViewIdException();
}
}
else if (viewId != null && mapping.getUrlPattern().startsWith(viewId))
{
throw new InvalidViewIdException(viewId);
}
//if(viewId != null)