【发布时间】:2011-09-17 03:05:14
【问题描述】:
我的应用程序允许用户在消息字段中键入文本,并且当他键入时,它必须允许管理员在不同的控制台中查看正在键入的内容。
为此 我需要定期将数据发送到托管 bean 并从那里发送到业务层。
<h:form>
Name : <h:inputText id="name" value="#{clockBean.name}"/>
Message: <h:inputText id="age" value="#{clockBean.msg}"/>
<a4j:poll id="poll" interval="20000" enabled="#{clockBean.enabled}" action="#
{clockBean.process}" render="clock,counter"/>
<a4j:log/>
</h:form>
我有 name 和 msg 的 managedBean 属性,我需要访问 name 和 msg 属性并在处理它们时将它们发送到业务层 clockBean 托管 Bean 的 process() 方法。
@ManagedBean
@ViewScoped
public class ClockBean implements Serializable{
private string msg;
private string name;
private boolean enabled;
public void process(){
System.out.println("timer event calling *** - msg is "+msg+" : name is "+name); }
//getters setters & rest of the code
目前,我的 bean 范围为 ViewScoped,当轮询每 20 秒运行一次时,我得到 2 个字段的空值。 当轮询在给定的时间间隔内运行时,如何获取 name 和 msg 属性值? 有没有更好的方法来解决这个问题?
【问题讨论】:
标签: jquery ajax jsf jsf-2 richfaces