Skip to content

Commit 61bb884

Browse files
committed
Fix #5606: shouldWriteIdAttribute should always be true for UICommand
1 parent 790f631 commit 61bb884

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

impl/src/main/java/com/sun/faces/renderkit/html_basic/HtmlBasicRenderer.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import com.sun.faces.util.Util;
4646

4747
import jakarta.faces.component.NamingContainer;
48+
import jakarta.faces.component.UICommand;
4849
import jakarta.faces.component.UIComponent;
4950
import jakarta.faces.component.UIInput;
5051
import jakarta.faces.component.UIParameter;
@@ -579,13 +580,16 @@ protected boolean shouldWriteIdAttribute(UIComponent component) {
579580
// By default we only write the id attribute if:
580581
//
581582
// - We have a non-auto-generated id, or...
582-
// - We have client behaviors.
583+
// - We have client behaviors, or...
584+
// - The component is a UICommand (its CSP-style click listener is attached
585+
// via mojarra.ael(clientId, ...) which needs the id on the rendered element).
583586
//
584587
// We assume that if client behaviors are present, they
585588
// may need access to the id (AjaxBehavior certainly does).
586589

587590
String id;
588591
return null != (id = component.getId()) && (!id.startsWith(UIViewRoot.UNIQUE_ID_PREFIX)
592+
|| component instanceof UICommand
589593
|| component instanceof ClientBehaviorHolder && !((ClientBehaviorHolder) component).getClientBehaviors().isEmpty());
590594
}
591595

0 commit comments

Comments
 (0)