【问题标题】:JSF2.2.1 + form binding + ViewScoped troubleJSF2.2.1 + 表单绑定 + ViewScoped 麻烦
【发布时间】:2014-01-19 06:50:04
【问题描述】:

我有以下 JSF 页面来尝试标准 JSF2.2.1 和 Primefaces4 CommandLink:

<h:form id="test3" binding="#{test3.hf}">
    <h:commandLink value="Test3" action="#{test3.print('PROVA.....')}" />
    <br />
    <p:commandLink value="PFtest" action="#{test3.print('PROVA.....')}" />
</h:form>

... 以及相关的 ViewScoped 托管 bean:

@ManagedBean(name="test3")
@ViewScoped
public class Test3 implements Serializable {
    HtmlForm hf;    

    public Test3() {
        super();
    }

    public HtmlForm getHf() {
        return hf;
    }
    public void setHf(HtmlForm hf) {
        this.hf = hf;
    }

    public String print(String text) {
        System.out.println(text + " " + System.currentTimeMillis());
        System.out.println(hf.getChildren().size());
        return null;
    }

}

奇怪的行为是,单击两个 CommandLink 之一,打印方法被调用两次 !!!
如果我避免表单绑定或向 CommandLink 组件添加额外的绑定,则不会出现此问题。

你怎么看? 谢谢。

【问题讨论】:

  • 为什么会有两个相同动作的commandLink?
  • 这是一个简单的测试用例,用于尝试标准 Mojarra 组件和 Primefaces 组件(...但行为相同...)。 “print”方法仅用于调试操作。
  • 这是一个有趣的问题。 Mojarra 2.1.26 也发生在我身上。但是,将 bean 范围更改为 @RequestScoped 会带来所需的行为...
  • 是的,@RequestScoped 工作正常,....但我需要@ViewScoped :-)
  • 似乎是一个错误。由于某种原因,UIViewRoot#queueEvent 被调用了两次,因此两个事件排队等待执行,因此该方法被调用。很高兴知道 MyFaces 是否也会发生这种情况......

标签: jsf-2 binding mojarra jsf-2.2 view-scope


【解决方案1】:

由 Mojarra 2.2.5 解决。 感谢您的贡献。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-24
    • 2015-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-06
    • 2023-03-22
    • 2016-01-15
    相关资源
    最近更新 更多