Theme
TriStateManyCheckbox
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
Source
<!-- 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"
                             value="#{triSateManyCheckBoxController.selectedOptionsTriStateConvertedInline}"
                             converter="triStateManyCheckboxConverter">
        <f:selectItems value="#{triSateManyCheckBoxController.basicOptions}"/>
    </pe:triStateManyCheckbox>
    
    <h:outputText value="With f:converter:"/>
    <pe:triStateManyCheckbox id="TriBasicConverterInline"
                             value="#{triSateManyCheckBoxController.selectedOptionsTriStateConverted}">
        <f:converter converterId="triStateManyCheckboxConverter"/>
        <f:selectItems value="#{triSateManyCheckBoxController.basicOptions}"/>
    </pe:triStateManyCheckbox>    

    <h:outputText value="With Validator, 0 is not allowed:"/>
    <pe:triStateManyCheckbox id="TriAjax"
                             value="#{triSateManyCheckBoxController.selectedOptionsTriStateAjax}"
                             stateOneIcon="ui-icon-home"
                             stateTwoIcon="ui-icon-heart"
                             stateThreeIcon="ui-icon-star"
                             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}"/>
    </pe:triStateManyCheckbox>
</h:panelGrid>

<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()}"
                    var="optionsB">
            #{optionsB} #{triSateManyCheckBoxController.selectedOptionsTriStateConvertedInline.get(optionsB)}
        </p:dataList>
        
        <p:dataList value="#{triSateManyCheckBoxController.selectedOptionsTriStateConverted.keySet().toArray()}"
                    var="optionsB">
            #{optionsB} #{triSateManyCheckBoxController.selectedOptionsTriStateConverted.get(optionsB)}
        </p:dataList>

        <p:dataList value="#{triSateManyCheckBoxController.selectedOptionsTriStateAjax.keySet().toArray()}"
                    var="optionsA">
            #{optionsA} state = #{triSateManyCheckBoxController.selectedOptionsTriStateAjax.get(optionsA)}
        </p:dataList>
    </p:outputPanel>
</p:dialog>
            
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-2018, PrimeFaces: 6.2, PrimeFaces Extensions: 6.2.8, JSF: mojarra 2.3.2, Server: jetty/9.4.2.v20170220, Build time: 2018-08-09 14:37
occured!
Message:
Timestamp:
StackTrace: