JSF-有关生命周期的另一个问题 [英] JSF - Another question on Lifecycle

查看:151
本文介绍了JSF-有关生命周期的另一个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我想了解JSF生命周期中的一些功能.让我开始吧:

Today I'd like to know some features on the JSF Lifecycle. Let me start :

1-阶段2:应用请求值-在此阶段中,视图中的每个组件都会在请求中搜索其值并将新值设置为它们

嗯,好的.因此,将由于先前的Beans参数而构建了View.之后,有一个局部视图,使用请求值生成. (对吗?稍后,在3°阶段,将对它们进行比较).但是,例如,在最后一个视图的创建过程中,请求列表中的值是否不存在?值将为空吗?

Uhm, ok nice. So, the View will be built due to the previous Beans parameters. After, there is a partial View, generated with the request values. (Right? Later, in the 3° phase, they will be compared) . But, for example, if a values in the request list is absent during the creation of this last view? Values will be null?

2-阶段5:调用应用程序-将请求的所有值成功设置到后备bean之后,将处理在应用请求值"阶段排队的操作事件.在我们的示例中,提交按钮"操作方法.

这根本不清楚.目前,我(在bean上)具有从上一个阶段更新的值(如果验证和应用请求没有失败).好吧,那么现在会发生什么呢?什么意思是在申请请求值阶段排队的动作事件将被处理?这意味着,例如,如果操作是 Submit ,则过程完成了吗?这就是为什么ajax调用(如果未在2°阶段呈现)将失败的原因?还是失败了?

This is not clear at all. At this moment i have (on the beans) the values updated from the previous Phase (If the validation and the apply request aren't failed). Ok, so now what happens? What means the action events queued during the apply request values phase will be processed? It means that, for example, if the action is Submit the process is finished? That's why an ajax call, if not rendered in the 2° phase, will fail? Or where it fails?

3-阶段6:渲染响应-在此阶段,组件树将呈现给客户端.

这意味着使用更新的bean值来更新服务器上的View吗?而且,此后,是否从该视图创建HTML代码?还是只是制作了HTML代码并保存了View状态?

It means that the View on the server is updated by using the updated bean values? And, after this, the HTML code is created from this View? Or just it made the HTML code and save the View status?

希望你能帮助我:)

推荐答案

阶段2:应用请求值-在此阶段,视图中的每个组件都会在请求中搜索其值并为其设置新值

嗯,好的.因此,将由于先前的Beans参数而构建了View.之后,有一个局部视图,使用请求值生成. (对吗?稍后,在3°阶段,将对它们进行比较).但是,例如,在最后一个视图的创建过程中,请求列表中的值是否不存在?值将为空吗?

Uhm, ok nice. So, the View will be built due to the previous Beans parameters. After, there is a partial View, generated with the request values. (Right? Later, in the 3° phase, they will be compared) . But, for example, if a values in the request list is absent during the creation of this last view? Values will be null?

基本上发生了以下情况(此处,input

Basically the following is happening under the covers (here, input is UIInput and request is HttpServletRequest):

if (input.isRendered()) {
    String value = request.getParameter(input.getClientId());
    if (value != null) {
        input.setSubmittedValue(value);
    }
}

因此,如果没有请求参数,它们将保持不变.不会使用null设置它们,而只是保留默认值.

So, they will be untouched if there's no request parameter. They won't be set with null and just kept default.

阶段5:调用应用程序-将请求的所有值成功设置到备用Bean后,将处理在应用请求值"阶段排队的操作事件.在我们的示例中,提交按钮"操作方法.

这根本不清楚.目前,我(在bean上)具有从上一个阶段更新的值(如果验证和应用请求没有失败).好吧,那么现在会发生什么呢?这意味着将处理在申请请求值"阶段排队的操作事件?这意味着,例如,如果操作为提交",则过程完成了吗?这就是为什么ajax调用(如果未在2°阶段呈现)将失败的原因?还是失败了?

This is not clear at all. At this moment i have (on the beans) the values updated from the previous Phase (If the validation and the apply request aren't failed). Ok, so now what happens? What means the action events queued during the apply request values phase will be processed? It means that, for example, if the action is Submit the process is finished? That's why an ajax call, if not rendered in the 2° phase, will fail? Or where it fails?

在第二阶段基本上期间,也会发生以下情况(此处command

During 2nd phase basically the following will also happen (here, command is UICommand, request is HttpServletRequest and ActionEvent is ActionEvent):

if (command.isRendered()) {
    String value = request.getParameter(command.getClientId());
    if (value != null) {
        command.queueEvent(new ActionEvent(command)); // Queue for INVOKE_ACTION.
    }
}

然后,在调用应用程序阶段,将为特定阶段排队的所有事件都将被调用.

Then, during invoke application phase, all events which are queued for the particular phase will be invoked.

阶段6:渲染响应-在此阶段,组件树将呈现给客户端.

这意味着使用更新的bean值来更新服务器上的View吗?而且,此后,是否从该视图创建HTML代码?还是只是制作了HTML代码并保存了View状态?

It means that the View on the server is updated by using the updated bean values? And, after this, the HTML code is created from this View? Or just it made the HTML code and save the View status?

在此阶段,JSF遍历了组件树,所有组件都将被编码(将调用

During this phase JSF walks through the component tree and all components will be encoded (will invoke the Renderer of all components, by default a HTML renderer). During encoding, the values will just be obtained from the model. The view itself won't be updated. Basically:

facesContext.getViewRoot().encodeAll();

这篇关于JSF-有关生命周期的另一个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆