[英]Is it possible to “grey-out” a h:selectBooleanCheckbox ?
Currently I have conditions in my render attribute that decide whether the checkbox is displayed or not. 目前,我的渲染属性中有条件决定是否显示该复选框。 Instead, I want the conditions to dictate whether the checkbox is clickable or greyed out (to indicate the user does not have permission to click it).
相反,我希望条件决定该复选框是可单击的还是灰色的(以表明用户无权单击它)。
I am a complete noob to JSF. 我对JSF完全陌生。
try something like this 尝试这样的事情
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;
}
}
and 和
<?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.