JSF h:CommandButton don't work with f:ajax?

社会主义新天地 提交于 2020-01-06 07:59:29

问题


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, if I change the component to:

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

It works perfect. Am I doing something wrong using 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.


回答1:


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' />
...

See the execute section of the javadoc:

... 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.



来源:https://stackoverflow.com/questions/15670819/jsf-hcommandbutton-dont-work-with-fajax

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!