通过选择复选框启用和禁用组件 [英] Enabling and disabling components via select checkbox

查看:107
本文介绍了通过选择复选框启用和禁用组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有组件,我正在尝试禁用下面的panelGrid.

I have component and I'm trying disable panelGrid below.

<h:selectBooleanCheckbox id="checkboxId" value="#{bean.checked}">
    <p:ajax update="panelId" event="click"/>                                    
</h:selectBooleanCheckbox>
<h:panelGrid id="panelId" rendered="#{!bean.checked}">
    <h:outputLabel>some text</h:outputLabel>
    <h:outputLabel>#registrationBB.registrationModel.homeAddress.actualAddressMathWithRegistration}</h:outputLabel>
</h:panelGrid>

因此,单击复选框不会生效.检查指示符甚至没有出现在复选框组件上,并且值bean:checked不会发送到服务器. 我也尝试使用.出现检查指示符,但面板未刷新

As a result the clicking on checkbox doesn't take no effect. The check indicator doesn't even appear on checkbox component and value bean:checked doesn't sent to the server. I tried to use also. Check indicator appeared but the panel is not refreshed

如何通过复选框使用更新?

How to use update via checkbox right?

推荐答案

下面的示例是我要工作的:

The example below is what I got to work:

<h:form>
    <h:selectBooleanCheckbox id="checkboxId" value="#{indexBean.checked}" >
        <p:ajax event="change" update="panelId" />
    </h:selectBooleanCheckbox>

    <h:panelGrid id="panelId" style="border:solid 1px black;" >
        <h:outputLabel rendered="#{!indexBean.checked}" >some text</h:outputLabel>
        <h:outputText rendered="#{!indexBean.checked}" value="some text 2" />
    </h:panelGrid>
</h:form>

我必须将<p:ajax>事件从单击更改为更改,以使复选框起作用.另一个问题是,如果不渲染<h:panelGrid>,则找不到ID更新,因此您希望将渲染的属性移动到<h:panelGrid>内部的组件,但仍要更新<h:panelGrid>.

I had to change the <p:ajax> event from click to change to get the checkbox working. The other issue is if you don't render the <h:panelGrid> the id can not be found to update, so you want to move the rendered attribute to the components inside your <h:panelGrid> but still update the <h:panelGrid>.

这篇关于通过选择复选框启用和禁用组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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