簡體   English   中英

是否可以“灰出” ah:selectBooleanCheckbox?

[英]Is it possible to “grey-out” a h:selectBooleanCheckbox ?

目前,我的渲染屬性中有條件決定是否顯示該復選框。 相反,我希望條件決定該復選框是可單擊的還是灰色的(以表明用戶無權單擊它)。

我對JSF完全陌生。

嘗試這樣的事情

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;



@ManagedBean
@ViewScoped
public class MyMB implements Serializable{

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    private boolean disabledCheckbox = false;

    public void toggle(){
        this.disabledCheckbox = !this.disabledCheckbox;
    }

    public boolean isDisabledCheckbox() {
        return disabledCheckbox;
    }

    public void setDisabledCheckbox(boolean disabledCheckbox) {
        this.disabledCheckbox = disabledCheckbox;
    }

}

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">

<h:head>
</h:head>
<h:body>

    <h:form>
        <p:panel>
            <h:selectBooleanCheckbox id="cb" disabled="#{myMB.disabledCheckbox}"
                value="#{true}" />
            <p:commandButton action="#{myMB.toggle}" update="cb" />
        </p:panel>
    </h:form>

</h:body>
</html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM