Sometimes, when using <h:commandLink>
, <h:commandButton>
or <f:ajax>
, the action
, actionListener
or listener
method associated with the tag are simply not being invoked. Or, the bean properties are not updated with submitted UIInput
values.
What are the possible causes and solutions for this?
I would mention one more thing that concerns Primefaces's
p:commandButton
!When you use a
p:commandButton
for the action that needs to be done on the server, you can not usetype="button"
because that is for Push buttons which are used to execute custom javascript without causing an ajax/non-ajax request to the server.For this purpose, you can dispense the
type
attribute (default value is"submit"
) or you can explicitly usetype="submit"
.Hope this will help someone!
One more possibility: if the symptom is that the first invocation works, but subsequent ones do not, you may be using PrimeFaces 3.x with JSF 2.2, as detailed here: No ViewState is sent.
Got stuck with this issue myself and found one more cause for this problem. If you don't have setter methods in your backing bean for the properties used in your *.xhtml , then the action is simply not invoked.
While my answer isn't 100% applicable, but most search engines find this as the first hit, I decided to post it nontheless:
If you're using PrimeFaces (or some similar API)
p:commandButton
orp:commandLink
, chances are that you have forgotten to explicitly addprocess="@this"
to your command components.As the PrimeFaces User's Guide states in section 3.18, the defaults for
process
andupdate
are both@form
, which pretty much opposes the defaults you might expect from plain JSFf:ajax
or RichFaces, which areexecute="@this"
andrender="@none"
respectively.Just took me a looong time to find out. (... and I think it's rather unclever to use defaults that are different from JSF!)
To solve;
I recently ran into a problem with a UICommand not invoking in a JSF 1.2 application using IBM Extended Faces Components.
I had a command button on a row of a datatable (the extended version, so
<hx:datatable>
) and the UICommand would not fire from certain rows from the table (the rows that would not fire were the rows greater than the default row display size).I had a drop-down component for selecting number of rows to display. The value backing this field was in
RequestScope
. The data backing the table itself was in a sort ofViewScope
(in reality, temporarily inSessionScope
).If the row display was increased via the control which value was also bound to the datatable's
rows
attribute, none of the rows displayed as a result of this change could fire the UICommand when clicked.Placing this attribute in the same scope as the table data itself fixed the problem.
I think this is alluded to in BalusC #4 above, but not only did the table value need to be View or Session scoped but also the attribute controlling the number of rows to display on that table.