h:commandLink rendered working disabled not working
jsf-2
Solution
Have a look at the generated HTML. Setting disabled=true will produce a span-Tag.
If the "disabled" attribute is specified, do not render the HTML "a" anchor element or its "href" attribute. Instead, render a "span" element.
https://javaserverfaces.java.net/nonav/docs/2.0/pdldocs/facelets/h/commandLink.html
If there is a attribute onClick, this will produce the client-side behaviour.
Problem
I have a page on which i am displaying a prime faces table using p dataTable whose value is coming from session scoped bean. One of the columns in table is a commmandLink. I have a h:commandLink under p:columns in the table. I need to render the h:commandLink depending on specific condition. I need to disable / enable the h:commandLink on another condition. The logic written for rendering the h:commandLink works correctly, but logic for disabling it does not work. the h:commandLink has a nested outputText and graphicImage. Even defaulting disabled = "true" does not work. when i click on image displayed for commandLink, i see the dialog which i am displaying using javascript on commandLink onClick. ``` <p:dataTable value="#{myBean.items}" id="pdatatableid" var="oneItem" rowIndexVar="rowIdxVar" rows="#{myBean.displayRows}" cellspacing="0" width="500px" emptyMessage="Item(s) requested cannot be found" lazy="true" first="#{myBean.firstRow}" paginator="true" paginatorPosition="top"> <p:columns value="#{myBean.headerList}" var="colHeader" columnIndexVar="colIdx" sortBy="#{oneItem[colHeader.attribute]}" headerText="#{colHeader.label}" rendered="#{not empty myBean.headerList}"> <h:commandLink action="#{myBean.performLinkAction(colHeader)}" rendered="#{colHeader.commandLink && colHeader.linkAction != 'removeWorkItemEscalation' && colHeader.linkAction == 'orderCancellation' && oneItem.cancelOrder}" disabled="true" immediate="true" onclick="#{rich:component('cancellationDlg')}.show();return false;"> <h:outputText rendered="#{(colHeader.valueImage) == null}" value="#{myBean.getColumnValue(colHeader,colIdx)}" /> <h:graphicImage rendered="#{(colHeader.valueImage) != null}" value="#{colHeader.valueImage}" alt="#{myBean.getColumnValue(colHeader,colIdx) ? 'Yes':'No'}" title="Cancel Quote" /> </h:commandLink> </p:columns> </p:dataTable> public boolean getCancelOrder(){ boolean cancelOrder = false; if(!StringUtils.isEmpty(getOrderVO().getRealm()) && "NETWORK".equalsIgnoreCase(getOrderVO().getRealm())){ cancelOrder = true; } return cancelOrder; } above is the bean method used for rendered attribute which is working. Similar implementation and even defaulting disabled to "true" does not work. ```