JSF h:CommandButton不能与f:ajax一起使用吗? [英] JSF h:CommandButton don't work with f:ajax?

查看:71
本文介绍了JSF h:CommandButton不能与f:ajax一起使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to submit a form with the following code but it doesn't populate the fields in the bean:

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

Althoug,如果我将组件更改为:

Althoug, if I change the component to:

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

效果完美.我使用h:commandButton做错了吗?

It works perfect. Am I doing something wrong using h:commandButton?

我曾尝试从actionListener更改为action,因为在此之前我遇到了问题,但在h:commandButton上却不管用.

I tried to change from actionListener to action since I had problems before with this, but it didn't work either way with h:commandButton.

推荐答案

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

By default, the f:ajax will only execute @this meaning it will only submit the action button, not any of the values of inputs in the form. Try this:

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

请参见

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

... If a literal is specified the ids must be space delimited. Any of the keywords "@this", "@form", "@all", "@none" may be specified in the id list. If not specified, the default value of "@this" is assumed. For example, @this clientIdOne clientIdTwo.

这篇关于JSF h:CommandButton不能与f:ajax一起使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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