JSF规范,Standard Request Processing Lifecycle Phases
尝试翻译了一下JSF12规范中关于6大处理过程的内容,有些地方不太明确.不过感觉对JSF的了解还是有一定帮助.自学用.
Standard Request Processing Lifecycle PhasesThe standard phases of the request processing lifecycle are described in the following subsections.
1 Restore View The JSF implementation must perform the following tasks during the Restore View phase of the request processing lifecycle:
在请求处理生命周期的Restore View阶段中,JSF实现必须执行以下任务:
■ Call initView() on the ViewHandler. This will set the character encoding properly for this request.
在ViewHandler中调用initView()。为当前请求设置编码属性。
■ Examine the FacesContext instance for the current request. If it already contains a UIViewRoot:
检测当前请求的FacesContext。如果已包含UIViewRoot,则:
■ Set the locale on this UIViewRoot to the value returned by the
getRequestLocale() method on the ExternalContext for this request.
在UIViewRoot上为当前请求设置本地信息,由ExternalContext的getRequestLocale()方法获取该值。
■ For each component in the component tree, determine if a ValueExpression for “binding” is present. If so, call the setValue() method on this ValueExpression, passing the component instance on which it was found.
对于组件树中的每个组件,要确定是否出现ValueExpression的“bingding”属性。如果有则调用ValueExpression的setValue()方法,传递该组建实例(作为参数?)。
■ Take no further action during this phase, and return. The presence of a UIViewRoot already installed in the FacesContext before the Restore View Phase implementation indicates that the phase should assume the view has already been restored by other means.
在此阶段无进一步的行为,则返回。在Restore View 阶段前,出现的UIViewRoot已安置在FacesContext中,JSf实现应当使当前view已经被其他方式重建。
■ Determine if this request is a postback or initial request by executing the following algorithm. Find the render-kit-id for the current request by calling calculateRenderKitId() on the Application’s ViewHandler. Get that RenderKit’s ResponseStateManager and call its isPostback() method, passing the current FacesContext.
可以通过以下算法确定请求是postback还是initial请求。通过调用Application’s ViewHandler的calculateRenderKitId()方法查找当前请求的render-kit-id。获得render-kit-id相应的RenderKit’s ResponseStateManager,调用isPostback()方法确定请求方式,同时传递FacesContext作为参数。
■ A request that is a non-postback request must call FacesContext.renderResponse() to cause intervening phases to be skipped.
非postback(初始)请求必须调用FacesContext.renderResponse()以跳过中间阶段。
■ If the request is a postback, call ViewHandler.restoreView(), passing the FacesContext instance for the current request and the view identifier, and returning a UIViewRoot for the restored view. If the return from ViewHandler.restoreView() is null, throw a ViewExpiredException with an appropriate error message.
javax.faces.application.ViewExpiredException is a FacesException
that must be thrown to signal to the application that the expected view was not returned for the view identifier. An application may choose to perform some action based on this exception.
如果是postback请求,调用ViewHandler.restoreView(),传递当前FacesContext实例和view ID标示作为参数,返回UIViewRoot作为重建view。如果返回null,则抛出相应错误信息的ViewExpiredException异常。javax.faces.application.ViewExpiredException用来表示应用未返回view ID标示相应的view。基于这样的异常,应用可采取相应的措施。
■ For each component in the component tree, determine if a ValueExpression for “binding” is present. If so, call the setValue() method on this ValueExpression, passing the component instance on which it was found. Do this in a “parent-first” fashion, calling the setValue() method and then traversing the children.
对于组件树中的每个组件,确定ValueExpression的“bingding”是否出现 。如果有则调用setValue()方法,传递该组件实例作为参数。以“父节点优先”的方式调用setValue()方法,并遍历所有子节点。
■ If the request is a non-postback, call ViewHandler.createView(), passing the FacesContext instance for the current request and the view identifier.
如果为non-postback请求,则以当前请求的FaceContext实例和view Id标示为参数,调用ViewHandler.createView()方法