PrimeFaces p:commandButton ajax="false" inside a p:confirmDialog not calling action

1 week ago 4
ARTICLE AD BOX

I have the requirement to basically use a PrimeFaces p:confirmDialog to ask a simple Yes-No question. The original idea was to use a p:commandButton ajax="true", call an action to update the status and stay on the same page (use a PF @form UI update + display a message to the user):

<p:confirmDialog global="true" showEffect="fade" hideEffect="fade" responsive="true" style="max-width: 1000px;"> <p:commandButton value="No" styleClass="ui-button-secondary ui-confirmdialog-no" type="button" /> <p:commandButton value="Yes" ajax="true" action="#{ergebnisTextbausteinStatusBean.finalizeStatus()}" process="@this" update="@form template_msg_summary" styleClass="ui-confirmdialog-yes" /> </p:confirmDialog>

This works as expected. The action is called, status in DB is updated and the UI shows that everything is fine.

Now the customer decided to change this and do a navigation to another page on Yes (if successful).

So the choice was to try a <p:commandButton ajax="false"> (as being used in the whole project, so this button's code is basically an adjusted copy from some other place in the project).

Dialog + button using ajax="false":

<p:confirmDialog global="true" showEffect="fade" hideEffect="fade" responsive="true" style="max-width: 1000px;"> <p:commandButton value="No" styleClass="ui-button-secondary ui-confirmdialog-no" type="button" /> <template:formElementSpacer elementWidth="6" elementWidthM="2" /> <p:commandButton value="Yes" ajax="false" action="#{ergebnisTextbausteinStatusBean.finalizeStatus()}" styleClass="ui-confirmdialog-yes" /> </p:confirmDialog>

However, the action is never called.

I then installed a JSF PhaseListener (hooked in faces-config.xml) to check some things:

public class AnyPhaseListener implements PhaseListener { @Override public PhaseId getPhaseId() { return PhaseId.ANY_PHASE; } @Override public void beforePhase(PhaseEvent event) { System.out.println("----------------- " + getClass().getSimpleName() + " BEFORE PHASE: " + event.getPhaseId()); } @Override public void afterPhase(PhaseEvent event) { System.out.println("----------------- " + getClass().getSimpleName() + " AFTER PHASE: " + event.getPhaseId()); } }

This print all phases being visited for every request.

For the (working) AJAX true button above, the logged sysouts are:

[3/26/26 19:58:26:095 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: RESTORE_VIEW(1) [3/26/26 19:58:26:105 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: RESTORE_VIEW(1) [3/26/26 19:58:26:105 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: APPLY_REQUEST_VALUES(2) [3/26/26 19:58:26:106 CET] 000016f1 HtmlRendererU W There should always be a submitted value for an input if it is rendered, its form is submitted, and it was not originally rendered disabled or read-only. You cannot submit a form after disabling an input element via javascript. Consider setting read-only to true instead or resetting the disabled value back to false prior to form submission. Component : {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /pages/auskunftsersuchen/ergebnisTextbaustein.xhtml][Class: javax.faces.component.html.HtmlBody,Id: j_id_d][Class: javax.faces.component.html.HtmlInputHidden,Id: j_id_3h]} [3/26/26 19:58:26:106 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: APPLY_REQUEST_VALUES(2) [3/26/26 19:58:26:106 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: PROCESS_VALIDATIONS(3) [3/26/26 19:58:26:107 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: PROCESS_VALIDATIONS(3) [3/26/26 19:58:26:107 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: UPDATE_MODEL_VALUES(4) [3/26/26 19:58:26:108 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: UPDATE_MODEL_VALUES(4) [3/26/26 19:58:26:108 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: INVOKE_APPLICATION(5) [3/26/26 19:58:26:108 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: INVOKE_APPLICATION(5) [3/26/26 19:58:26:109 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: RENDER_RESPONSE(6) [3/26/26 19:58:26:123 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: RENDER_RESPONSE(6) [3/26/26 19:58:28:160 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: RESTORE_VIEW(1) [3/26/26 19:58:28:172 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: RESTORE_VIEW(1) [3/26/26 19:58:28:173 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: APPLY_REQUEST_VALUES(2) [3/26/26 19:58:28:173 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: APPLY_REQUEST_VALUES(2) [3/26/26 19:58:28:173 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: PROCESS_VALIDATIONS(3) [3/26/26 19:58:28:174 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: PROCESS_VALIDATIONS(3) [3/26/26 19:58:28:174 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: UPDATE_MODEL_VALUES(4) [3/26/26 19:58:28:174 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: UPDATE_MODEL_VALUES(4) [3/26/26 19:58:28:174 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: INVOKE_APPLICATION(5) [3/26/26 19:58:28:175 CET] 000016f1 SystemOut O ------------------------- ErgebnisTextbausteinStatusBean.finalizeStatus()! [3/26/26 19:58:28:175 CET] 000016f1 SystemOut O ------------------------- 2 [3/26/26 19:58:28:649 CET] 000016f1 SystemOut O ------------------------- 3 [3/26/26 19:58:30:510 CET] 000016f1 SystemOut O ------------------------- 4 [3/26/26 19:58:30:510 CET] 000016f1 SystemOut O ------------------------- 5 [3/26/26 19:58:30:510 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: INVOKE_APPLICATION(5) [3/26/26 19:58:30:511 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: RENDER_RESPONSE(6) [3/26/26 19:58:30:661 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: RENDER_RESPONSE(6) [3/26/26 19:58:34:658 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: RESTORE_VIEW(1) [3/26/26 19:58:34:667 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: RESTORE_VIEW(1) [3/26/26 19:58:34:667 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: APPLY_REQUEST_VALUES(2) [3/26/26 19:58:34:668 CET] 000016f1 HtmlRendererU W There should always be a submitted value for an input if it is rendered, its form is submitted, and it was not originally rendered disabled or read-only. You cannot submit a form after disabling an input element via javascript. Consider setting read-only to true instead or resetting the disabled value back to false prior to form submission. Component : {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /pages/auskunftsersuchen/ergebnisTextbaustein.xhtml][Class: javax.faces.component.html.HtmlBody,Id: j_id_d][Class: javax.faces.component.html.HtmlInputHidden,Id: j_id_3h]} [3/26/26 19:58:34:668 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: APPLY_REQUEST_VALUES(2) [3/26/26 19:58:34:668 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: PROCESS_VALIDATIONS(3) [3/26/26 19:58:34:669 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: PROCESS_VALIDATIONS(3) [3/26/26 19:58:34:669 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: UPDATE_MODEL_VALUES(4) [3/26/26 19:58:34:669 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: UPDATE_MODEL_VALUES(4) [3/26/26 19:58:34:670 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: INVOKE_APPLICATION(5) [3/26/26 19:58:34:670 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: INVOKE_APPLICATION(5) [3/26/26 19:58:34:670 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: RENDER_RESPONSE(6) [3/26/26 19:58:34:680 CET] 000016f1 SystemOut O ----------------- AnyPhaseListener AFTER PHASE: RENDER_RESPONSE(6)

Please take note of the `finalizeStatus()` call plus the 2-3-4-5 sysouts that I put into the action method.

The output for the AJAX false button is different:

[3/26/26 19:36:38:871 CET] 000016eb SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: RESTORE_VIEW(1) [3/26/26 19:36:38:879 CET] 000016eb SystemOut O ----------------- AnyPhaseListener AFTER PHASE: RESTORE_VIEW(1) [3/26/26 19:36:38:880 CET] 000016eb SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: APPLY_REQUEST_VALUES(2) [3/26/26 19:36:38:880 CET] 000016eb HtmlRendererU W There should always be a submitted value for an input if it is rendered, its form is submitted, and it was not originally rendered disabled or read-only. You cannot submit a form after disabling an input element via javascript. Consider setting read-only to true instead or resetting the disabled value back to false prior to form submission. Component : {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /pages/auskunftsersuchen/ergebnisTextbaustein.xhtml][Class: javax.faces.component.html.HtmlBody,Id: j_id_d][Class: javax.faces.component.html.HtmlInputHidden,Id: j_id_3h]} [3/26/26 19:36:38:880 CET] 000016eb SystemOut O ----------------- AnyPhaseListener AFTER PHASE: APPLY_REQUEST_VALUES(2) [3/26/26 19:36:38:880 CET] 000016eb SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: PROCESS_VALIDATIONS(3) [3/26/26 19:36:38:881 CET] 000016eb SystemOut O ----------------- AnyPhaseListener AFTER PHASE: PROCESS_VALIDATIONS(3) [3/26/26 19:36:38:881 CET] 000016eb SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: UPDATE_MODEL_VALUES(4) [3/26/26 19:36:38:881 CET] 000016eb SystemOut O ----------------- AnyPhaseListener AFTER PHASE: UPDATE_MODEL_VALUES(4) [3/26/26 19:36:38:882 CET] 000016eb SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: INVOKE_APPLICATION(5) [3/26/26 19:36:38:882 CET] 000016eb SystemOut O ----------------- AnyPhaseListener AFTER PHASE: INVOKE_APPLICATION(5) [3/26/26 19:36:38:882 CET] 000016eb SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: RENDER_RESPONSE(6) [3/26/26 19:36:38:891 CET] 000016eb SystemOut O ----------------- AnyPhaseListener AFTER PHASE: RENDER_RESPONSE(6) [3/26/26 19:36:45:492 CET] 000016eb SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: RESTORE_VIEW(1) [3/26/26 19:36:45:500 CET] 000016eb SystemOut O ----------------- AnyPhaseListener AFTER PHASE: RESTORE_VIEW(1) [3/26/26 19:36:45:501 CET] 000016eb SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: APPLY_REQUEST_VALUES(2) [3/26/26 19:36:45:501 CET] 000016eb HtmlRendererU W There should always be a submitted value for an input if it is rendered, its form is submitted, and it was not originally rendered disabled or read-only. You cannot submit a form after disabling an input element via javascript. Consider setting read-only to true instead or resetting the disabled value back to false prior to form submission. Component : {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /pages/auskunftsersuchen/ergebnisTextbaustein.xhtml][Class: javax.faces.component.html.HtmlBody,Id: j_id_d][Class: javax.faces.component.html.HtmlInputHidden,Id: j_id_3h]} [3/26/26 19:36:45:501 CET] 000016eb SystemOut O ----------------- AnyPhaseListener AFTER PHASE: APPLY_REQUEST_VALUES(2) [3/26/26 19:36:45:501 CET] 000016eb SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: PROCESS_VALIDATIONS(3) [3/26/26 19:36:45:502 CET] 000016eb SystemOut O ----------------- AnyPhaseListener AFTER PHASE: PROCESS_VALIDATIONS(3) [3/26/26 19:36:45:502 CET] 000016eb SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: UPDATE_MODEL_VALUES(4) [3/26/26 19:36:45:503 CET] 000016eb SystemOut O ----------------- AnyPhaseListener AFTER PHASE: UPDATE_MODEL_VALUES(4) [3/26/26 19:36:45:503 CET] 000016eb SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: INVOKE_APPLICATION(5) [3/26/26 19:36:45:503 CET] 000016eb SystemOut O ----------------- AnyPhaseListener AFTER PHASE: INVOKE_APPLICATION(5) [3/26/26 19:36:45:504 CET] 000016eb SystemOut O ----------------- AnyPhaseListener BEFORE PHASE: RENDER_RESPONSE(6) [3/26/26 19:36:45:515 CET] 000016eb SystemOut O ----------------- AnyPhaseListener AFTER PHASE: RENDER_RESPONSE(6)

This is missing the sysouts completely and this output shows to me that there's a complete request missing in the middle.

Don't know about the other two requests, one before and one after, but let's assume they are ok.

What is wrong with the code/solution here?

We are on an old WebSphere 9 server using JSF 2.2 and PrimeFaces 13.0.10

Read Entire Article