问题
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