【问题标题】:JSF h:CommandButton don't work with f:ajax?JSF h:CommandButton 不适用于 f:ajax?
【发布时间】:2013-03-27 22:33:07
【问题描述】:

我正在尝试使用以下代码提交表单,但它没有填充 bean 中的字段:

//input above
<h:commandButton actionListener="#{transferenciaVagaBean.search()}" value="Search">
  <f:ajax render="@form"/>
</h:commandButton>

不过,如果我将组件更改为:

//input above
<a4j:commandButton actionListener="#{transferenciaVagaBean.search()}" 
                   value="Search" 
                   render="@form" />

完美运行。我使用 h:commandButton 做错了吗?

我尝试从 actionListener 更改为 action,因为我之前遇到过这个问题,但它对 h:commandButton 的任何一种方式都不起作用。

【问题讨论】:

    标签: jsf ajax4jsf


    【解决方案1】:

    默认情况下,f:ajax 只会执行@this,这意味着它只会提交操作按钮,而不是表单中的任何输入值。试试这个:

    ...
    <f:ajax execute='@form' render='@form' />
    ...
    

    请参阅javadoc执行部分:

    ... 如果指定了文字,则 id 必须用空格分隔。任何一个 可以在 id 中指定关键字“@this”、“@form”、“@all”、“@none” 列表。如果未指定,则假定默认值为“@this”。为了 例如,@this clientIdOne clientIdTwo。

    【讨论】:

    • 天啊。那很简单。谢谢!
    猜你喜欢
    • 2011-12-31
    • 2012-01-10
    • 1970-01-01
    • 2013-06-08
    • 1970-01-01
    • 2012-10-13
    • 2013-08-22
    • 2011-08-20
    • 2015-06-23
    相关资源
    最近更新 更多