Jsf h:selectBooleanCheckbox第一次不起作用
我想制作一个输出文本,它根据checkbox的值显示;这是我的密码:Jsf h:selectBooleanCheckbox第一次不起作用,jsf,primefaces,Jsf,Primefaces,我想制作一个输出文本,它根据checkbox的值显示;这是我的密码: <?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/
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<body>
<ui:composition template="../WEB-INF/templates/template.xhtml">
<ui:define name="content">
<h:form id="formModifClt">
<h:outputText value="voulez-vous modifier cette image ?"/>
<h:selectBooleanCheckbox value="#{clientController.modifierImage}" >
<f:ajax event="click" listener="#{clientController.onChangeCheckBox()}" render="textPanel" />
</h:selectBooleanCheckbox>
<p:outputPanel id="textPanel" autoUpdate="true" >
<h:outputText value="Oui" rendered="#{clientController.modifierImage}" />
<h:outputText value="Non" rendered="#{!clientController.modifierImage}" />
</p:outputPanel>
<p:outputPanel autoUpdate="true" >
<h:outputText value="Logo" rendered="#{clientController.modifierImage}" id="logo" />
<p:fileUpload id="up" fileUploadListener="#{fileUploadController.handleFileUpload}"
mode="advanced"
sizeLimit="100000"
required="true"
allowTypes="/(\.|\/)(gif|jpe?g|png)$/" rendered="#{clientController.modifierImage}"/>
</p:outputPanel>
<p:commandButton action="#{clientController.modifClient()}" value="Modifier" ajax="false"/>
</h:form>
</ui:define>
</ui:composition>
</body>
使用balusC的解决方案更好(第一次单击时不会给出一个chcked checkButton),但问题仍然存在 乍一看,我看不到任何特定的事件和任何要重新渲染的组件,那么这如何作为10的开始呢
<h:form>
<h:selectBooleanCheckbox value="#{clientController.modifierImage}" >
<f:ajax event="click" listener="#{clientController.onChangeCheckBox()}" render="textPanel" />
</h:selectBooleanCheckbox>
<p:outputPanel id="textPanel" autoUpdate="true">
<h:outputText value="Yes" rendered="#{clientController.modifierImage}" />
<h:outputText value="No" rendered="#{!clientController.modifierImage}" />
</p:outputPanel>
</h:form>
如果需要进一步的帮助,请发布您的控制器类。我发现,有时,它取决于在当前页面之前调用的页面!我用ajax=“false”制作,效果很好 我也有同样的问题。在我看来,是
元素阻止了第一次单击时的更新。下面是它的样子:
<f:facet name="body">
<h:form>
<h:panelGroup id="bodyContainer">
<h:selectBooleanCheckbox title="#{bundle['some.good.text']}" value="#{bean.checkMe}">
<f:ajax render="bodyContainer" />
</h:selectBooleanCheckbox>
#{bundle['some.realy.good.text']}
<br />
</h:panelGroup>
</h:form>
</f:facet>
#{bundle['some.realy.good.text']}
但是当
被删除后,一切都恢复正常。你能发布你的clientController吗?控制器的作用域是什么?我发现事件是click而不是onclick,但第一次仍然不起作用<代码>onclick事件不存在。您混淆了HTML元素的onclick
属性,它应该在click
事件上触发一些JS函数处理程序。真正的事件名称是click
。我想知道这是否是回发问题
<f:facet name="body">
<h:form>
<h:panelGroup id="bodyContainer">
<h:selectBooleanCheckbox title="#{bundle['some.good.text']}" value="#{bean.checkMe}">
<f:ajax render="bodyContainer" />
</h:selectBooleanCheckbox>
#{bundle['some.realy.good.text']}
<br />
</h:panelGroup>
</h:form>
</f:facet>