public UIViewRoot createView ( FacesContext context , String viewId ) { checkNull ( context , "context" ) ; //checkNull(viewId, "viewId"); try { viewId = calculateViewId ( context , viewId ) ; Application application = context . getApplication ( ) ; // Create a new UIViewRoot object instance using Application.createComponent(UIViewRoot.COMPONENT_TYPE). UIViewRoot newViewRoot = ( UIViewRoot ) application . createComponent ( context , UIViewRoot . COMPONENT_TYPE , null ) ; UIViewRoot oldViewRoot = context . getViewRoot ( ) ; if ( oldViewRoot == null ) { // If not, this method must call calculateLocale() and calculateRenderKitId(), and store the results // as the values of the locale and renderKitId, proeprties, respectively, of the newly created // UIViewRoot. ViewHandler handler = application . getViewHandler ( ) ; newViewRoot . setLocale ( handler . calculateLocale ( context ) ) ; newViewRoot . setRenderKitId ( handler . calculateRenderKitId ( context ) ) ; } else { // If there is an existing UIViewRoot available on the FacesContext, this method must copy its locale // and renderKitId to this new view root newViewRoot . setLocale ( oldViewRoot . getLocale ( ) ) ; newViewRoot . setRenderKitId ( oldViewRoot . getRenderKitId ( ) ) ; } // TODO: VALIDATE - The spec is silent on the following line, but I feel bad if I don't set it newViewRoot . setViewId ( viewId ) ; return newViewRoot ; } catch ( InvalidViewIdException e ) { // If no viewId could be identified, or the viewId is exactly equal to the servlet mapping, // send the response error code SC_NOT_FOUND with a suitable message to the client. sendSourceNotFound ( context , e . getMessage ( ) ) ; // TODO: VALIDATE - Spec is silent on the return value when an error was sent return null ; } }
Process the specification required algorithm that is generic to all PDL .