0

I have populated multi select drop down list , i have a scenario like the color of the text in the dropdown should differ based on some condtions . i have populated the values in <f:selectItems>. I have attached the screen shot of the drop down by adding css to rendered html file. How could i add dynamic css for the label

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>

Expected Result using primefaces enter image description here

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Vivek Shankar
  • 691
  • 3
  • 14
  • 48
  • 1
    I did a similar implementation for `selectOneMenu`, maybe you'll find it useful: https://stackoverflow.com/a/19405903/1199132 Good luck ;-) – Aritz Sep 06 '18 at 17:32
  • thanks mate i would try it – Vivek Shankar Sep 07 '18 at 07:58
  • i am having multiple selection @XtremeBiker and selectonemenu doesnt allow multiple selection. p:selectCheckboxMenu allows multiple selection but doesnt has var . hence p:column will not work is there any i could achieve like selectmanymenu answer below posted – Vivek Shankar Sep 12 '18 at 08:05

1 Answers1

0

I achieved it by the following code,changed to selectManyMenu and added checkbox 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>
Vivek Shankar
  • 691
  • 3
  • 14
  • 48