我已经填充了多选下拉列表,我遇到了这样的情况,如下拉菜单中的文本颜色应根据某些条件而有所不同。我已经填充了<f:selectItems>中的值。通过将css添加到渲染的html文件中,我已附加了下拉菜单的屏幕快照。如何为标签添加动态CSS

xhtml:

<p:selectCheckboxMenu id="stackListDropDown" filter="true"
                        style="vertical-align:middle" filterMatchMode="contains"
                        value="#{stackListForPOCBean.selectedStackListFromDB}"
                        styleClass="help-inline selectOneMenuDefault">
                        <!-- <f:selectItem noSelectionOption="false" /> -->
                        <!-- <p:ajax event="change" process="@this"
                            listener="#{stackListForPOCBean.subjectSelectionChanged(stack)}" /> -->
                        <f:selectItems value="#{stackListForPOCBean.stackListFromDB}"
                            var="stack" itemLabel="#{stack.stackId} - #{stack.stackDesc}"
                            itemValue="#{stack.stackId}">
                        </f:selectItems>
                        <p:ajax update="stackLineGroup" process="@this "
                            listener="#{stackListForPOCBean.validateMultiSelectStackForPOC()}" />
                        <p:ajax event="toggleSelect" update="@this stackLineGroup"
                            listener="#{stackListForPOCBean.validateMultiSelectStackForPOC()}" />
                    </p:selectCheckboxMenu>


使用素数的预期结果
css - p:selectCheckboxMenu动态CSS-LMLPHP

最佳答案

我是通过以下代码实现的,更改为selectManyMenu并添加了复选框true

<p:selectManyMenu id="stackListDropDown"
                        styleClass="help-inline selectOneMenuManyDefault"
                        value="#{stackListForPOCBean.stackListSelected}" var="t"
                        filter="true" filterMatchMode="contains" showCheckbox="true">
                        <f:selectItems value="#{stackListForPOCBean.stackListFromDB}"
                            var="stack" itemLabel="#{stack.stackId} - #{stack.stackDesc}"
                            itemValue="#{stack}" />
                        <p:column>
                            <h:outputText value="#{t.stackId} - #{t.stackDesc}"
                                styleClass="#{t.stackColorStyle}" />
                        </p:column>
                        <p:ajax update="stackLineGroup" process="@this "
                            listener="#{stackListForPOCBean.validateMultiSelectStackForPOC()}" />
                    </p:selectManyMenu>

08-17 12:13