p:selectCheckboxMenu动态CSS

问题描述 投票:0回答:1

我已经填充了多选下拉列表,我有一个场景,如下拉列表中的文本颜色应根据一些条件而有所不同。我填写了<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>

使用primefaces enter image description here的预期结果

css jsf primefaces
1个回答
0
投票

我通过以下代码实现了它,更改为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>
© www.soinside.com 2019 - 2024. All rights reserved.