如何知道是否使用JavaScript选择了primefaces selectBooleanCheckbox? [英] How to know that primefaces selectBooleanCheckbox is selected or not using javascript?

查看:59
本文介绍了如何知道是否使用JavaScript选择了primefaces selectBooleanCheckbox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取p:selectBooleanCheckbox组件并检查是否使用javascript选择了它

I want to get p:selectBooleanCheckbox component and check if it is selected or not using javascript

<h:dataTable value="#{controller.list}" var="item">
    <h:column>
        <f:facet name="header">Ratio1</f:facet>
        <h:panelGrid columns="2">
            <p:inputText id="ratio1" readonly="#{true}" disabled="true" styleClass="ratio1"/>
            <h:outputText value="%" />
        </h:panelGrid>
        <p:selectBooleanCheckbox id="report1"  onchange="calculateTotalRatio()" value="#{controller.value}" valueChangeListener="#{fISHController.onCaseTestItemPatternReportFlagChange()}">    
        </p:selectBooleanCheckbox>          
    </h:column>

我想在calculateTotalRatio()函数上检查是否选中了该复选框,并根据其更新比率1输入带有值的文本

I want on calculateTotalRatio() function check if the checkbox is checked or not and depending on it update ratio1 input text with value

推荐答案

您可以定义selectBooleanCheckbox的widgetVar

You can define the widgetVar of your selectBooleanCheckbox

<p:selectBooleanCheckbox id="check" widgetVar="myCheckbox" value="#{myBacking.value}"/>

您可以通过以下方式在js中访问Primefaces对象

You can access in js the Primefaces object in these ways

directly with myCheckbox
PF("myCheckbox")
window["myCheckbox"]
PrimeFaces.widgets["myCheckbox"]

因此,要获取复选框状态,可以使用

So, to get the checkbox state you can use

myCheckbox.input.is(':checked')
PF("myCheckbox").input.is(':checked')
window["myCheckbox"].input.is(':checked')
PrimeFaces.widgets["myCheckbox"].input.is(':checked')

这篇关于如何知道是否使用JavaScript选择了primefaces selectBooleanCheckbox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆