通过选择复选框启用和禁用组件
我有组件,我正在尝试禁用下面的 panelGrid。
<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 不会发送到服务器。 我也尝试使用。检查指示器出现,但面板未刷新
如何通过复选框使用更新?
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>
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
下面的示例是我要工作的内容:
我必须将
事件从 click 更改为 Change 才能使复选框正常工作。另一个问题是,如果您不渲染
,则无法找到要更新的 id,因此您希望将渲染的属性移动到< 内的组件;h:panelGrid>
但仍更新
。The example below is what I got to work:
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>
.略有变化。您的支持 bean 字段不必是布尔值。如果你有一个带有 fields: 的支持 bean,
那么你可以在表单加载之前像这样初始化 myStringList:
那么你可以这样做:
A slight variation. Your backing bean field doesn't have to be a boolean. If you had a backing bean with fields:
then you initialize myStringList like this before the form load:
then you could do this: