With inline converter:
With f:converter:
With Validator, 0 is not allowed:
Selected Values
  • Cat 1
  • Fish 2
  • Dog 0
  • Cat 0
  • Fish 0
  • Dog 0
  • Tamara state = 1
  • Mauricio state = 1

<!-- This group is for coding -->
<p:growl id="growl" showDetail="false"/>
<h:panelGrid id="triStateGrid" columns="2" style="margin-bottom:10px" cellpadding="5">

    <h:outputText value="With inline converter:"/>
    <pe:triStateManyCheckbox id="TriBasicConverter"
        <f:selectItems value="#{triSateManyCheckBoxController.basicOptions}"/>
    <h:outputText value="With f:converter:"/>
    <pe:triStateManyCheckbox id="TriBasicConverterInline"
        <f:converter converterId="triStateManyCheckboxConverter"/>
        <f:selectItems value="#{triSateManyCheckBoxController.basicOptions}"/>

    <h:outputText value="With Validator, 0 is not allowed:"/>
    <pe:triStateManyCheckbox id="TriAjax"
                             validatorMessage="State 0 is not allowed">
        <f:selectItem itemLabel="Tamara" itemValue="Tamara"/>
        <f:selectItem itemLabel="Mauricio" itemValue="Mauricio"/>
        <f:validateLongRange minimum="1"/>
        <p:ajax update="growl" listener="#{triSateManyCheckBoxController.addMessage}"/>

<p:commandButton value="Submit" update="display" oncomplete="PF('dlg').show()"/>

<p:dialog header="Selected Values" modal="false" showEffect="fade" hideEffect="fade" widgetVar="dlg" width="240">
    <p:outputPanel id="display">
         <p:dataList value="#{triSateManyCheckBoxController.selectedOptionsTriStateConvertedInline.keySet().toArray()}"
            #{optionsB} #{triSateManyCheckBoxController.selectedOptionsTriStateConvertedInline.get(optionsB)}
        <p:dataList value="#{triSateManyCheckBoxController.selectedOptionsTriStateConverted.keySet().toArray()}"
            #{optionsB} #{triSateManyCheckBoxController.selectedOptionsTriStateConverted.get(optionsB)}

        <p:dataList value="#{triSateManyCheckBoxController.selectedOptionsTriStateAjax.keySet().toArray()}"
            #{optionsA} state = #{triSateManyCheckBoxController.selectedOptionsTriStateAjax.get(optionsA)}
Components and more
Documentation pe:triStateManyCheckbox
Attributes (move mouse over the names to see data types)
Name Description
id Unique identifier of the component in a namingContainer.
rendered Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding An EL expression referring to a server side UIComponent instance in a backing bean.
value Value of the component.
converter An EL expression or a literal text that defines a converter for the component. When it's an EL expression, it's resolved to a converter instance. In case it's a static text, it must refer to a converter id.
immediate When set true, process validations logic is executed at apply request values phase for this component. Default is false.
required Marks component as required.
validator A method expression referring to a method validationg the input.
valueChangeListener A method binding expression referring to a method for handling a valuchangeevent.
requiredMessage Message to display when required field validation fails.
converterMessage Message to display when conversion fails.
validatorMessage Message to display when validation fails.
widgetVar Name of the client side widget.
disabled Disable the component.
label User presentable name.
layout Layout of the checkboxes, valid values are �lineDirection�(horizontal) and �pageDirection�(vertical).
onchange Callback on change event.
style Inline style of the component.
styleClass Style class of the main Layout container element. Default value is null.
stateOneIcon Icon for StateOne as a css class.
stateTwoIcon Icon for StateTwo as a css class.
stateThreeIcon Icon for StateThree as a css class.
stateOneTitle Title for StateOne.
stateTwoTitle Title for StateTwo.
stateThreeTitle Title for StateThree.
tabindex The tab index to assign to the component, If not given, tabindex=0 will be assigned.
PrimeFaces Extensions Showcase - © 2011-2021,PrimeFaces: 11.0.0,PrimeFaces Extensions: 11.0.3,JSF: Apache MyFaces JSF-2.3 Core API 2.3.9,Server: jetty/9.4.36.v20210114,Build time: 2022-04-17 14:55