Skip to content

Commit

Permalink
Fix #11814: Add data-pf-form attribute to CommandLink to support Defa…
Browse files Browse the repository at this point in the history
…ultCommand usage
  • Loading branch information
BjornJaspersCegeka committed May 22, 2024
1 parent cbb0ada commit 37c05fa
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ protected void encodeMarkup(FacesContext context, CommandLink link) throws IOExc
ResponseWriter writer = context.getResponseWriter();
String clientId = link.getClientId(context);
Object label = link.getValue();
String form = link.getForm();

String request;
boolean ajax = link.isAjax();
Expand Down Expand Up @@ -101,16 +102,20 @@ protected void encodeMarkup(FacesContext context, CommandLink link) throws IOExc
writer.writeAttribute("tabindex", "-1", null);
}

if (!isValueBlank(form)) {
writer.writeAttribute("data-pf-form", form, null);
}

if (ajax) {
request = buildAjaxRequest(context, link);
}
else {
UIForm form = ComponentTraversalUtils.closestForm(link);
if (form == null) {
UIForm uiForm = ComponentTraversalUtils.closestForm(link);
if (uiForm == null) {
throw new FacesException("Commandlink \"" + clientId + "\" must be inside a form component");
}

request = buildNonAjaxRequest(context, link, form, clientId, true);
request = buildNonAjaxRequest(context, link, uiForm, clientId, true);
}

if (csvEnabled) {
Expand Down

0 comments on commit 37c05fa

Please sign in to comment.