简体   繁体   中英

Is there a JSF toggle component or a way to theme an h:selectBooleanCheckbox with images?

I tried using a toggle like below. Although it works, it breaks when used inside of a composite component - changing the singleSelect value outside of the component never updates inside the component:

<h:commandButton disabled="#{cc.attrs.singleSelect}"
                 image="/resources/img/collapse-single.gif">
    <f:ajax listener="#{cc.toggleSingleSelect}" render="#{cc.clientId}"/>
</h:commandButton>

<h:commandButton disabled="#{! cc.attrs.singleSelect}"
                 image="/resources/img/expand-single.gif">
    <f:ajax listener="#{cc.toggleSingleSelect}" render="#{cc.clientId}"/>
</h:commandButton>

But if I use a simple checkbox, it works fine:

<h:selectBooleanCheckbox value="#{cc.attrs.singleSelect}">
    <f:ajax render="#{cc.clientId}"/>
</h:selectBooleanCheckbox >

Is there something that behaves like a checkbox, but uses images?

I've decided to go with an ICEfaces solution and use their ace:checkboxButton:

<ace:checkboxButton value="#{cc.attrs.singleSelect}" styleClass="toggle">
    <ace:ajax render="#{cc.clientId}"/>
</ace:checkboxButton>

You are able to style it to use images:

http://icefaces-showcase.icesoft.org/showcase.jsf?grp=aceMenu&exp=checkboxButtonCustom

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM