如何在valueChangeListener方法中获取更新的模型值? [英] How to get updated model values in a valueChangeListener method?

查看:120
本文介绍了如何在valueChangeListener方法中获取更新的模型值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在valueChangeListener上遇到问题.我正在Weblogic 6.0上使用JSF 1.2.

I am stuck with an issue on valueChangeListener. I am using JSF 1.2 on Weblogic 6.0.

我有一个页面,在页面顶部有2个单选按钮,名称分别为Name1和Name2.单击Name1时,单选按钮下方将显示Name1详细信息(大约30个字段),单击Name2时,将显示Name2详细信息.现在,用户可以更新单击的命名详细信息.例如用户单击Name1并更改地址字段,然后单击Name2并更改Name2的年龄.当用户单击Name1时,应显示该地址以新值更新,并且再次单击该用户时,年龄应被更新.

I have a page, where on top of the page there are 2 radio buttons with name as Name1 and Name2. When Name1 is clicked, the Name1 details(there are about 30 fields) is displayed below the radio buttons and when Name2 is clicked, Name2 details is displayed. Now the user can updated the clicked named details. e.g. the user clicks on Name1 and changes the address field and then clicks on Name2 and changes the age of Name2. When the user clicks back Name1, the address should be shown updated with the new value and again when the user clicks on Name2, the age should be updated.

我使用了valueChangeListener来解决它,因为我需要更改事件的旧值和新值.问题是,由于在VALIDATION阶段结束时调用了valueChangeListener,因此我没有在valueChangeListener方法中获取Name1字段的更新地址.有人可以帮我解决任何问题吗?

I have used valueChangeListener to tackle it because I need the old and new value of the changed event. The problem is, as the valueChangeListener is invoked at the end of the VALIDATION phase, I am not getting the updated address of the Name1 field in the valueChangeListener method. Can someone help me out to get any workaround ?

推荐答案

当在VALIDATION阶段结束时调用valueChangeListener时,我没有在valueChangeListener方法中获取Name1字段的更新地址

将事件排队到INVOKE_ACTION阶段,使其像一个action(listener)方法一样.

Queue the event to the INVOKE_ACTION phase so that it acts like as an action(listener) method.

public void valueChangeListenerMethod(ValueChangeEvent event) {
    if (event.getPhaseId() != PhaseId.INVOKE_APPLICATION) {
        event.setPhaseId(PhaseId.INVOKE_APPLICATION);
        event.queue();
        return;
    }

    // Do your original job here. 
    // It will only be entered when current phase ID is INVOKE_APPLICATION.
}

由于INVOKE_ACTION阶段在UPDATE_MODEL_VALUES之后运行,因此更新的模型值将以通常的方式"提供.

As INVOKE_ACTION phase runs after UPDATE_MODEL_VALUES, the updated model values will be just available "the usual way".

这篇关于如何在valueChangeListener方法中获取更新的模型值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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