麻烦更新< p:outputpanel>
好的,我的问题是我无法从Ajax更新组件(CURSO),我真的不知道为什么。
这是我的代码:
Rol <h:selectManyCheckbox value="#{usuarioSession.roles}" id="admin" disabled="#{checkView.validarAdm}">
<f:selectItem itemValue="1" itemLabel="Administrador"></f:selectItem>
<p:ajax listener="#{checkView.checkBoxAdmin()}" update="est"></p:ajax>
</h:selectManyCheckbox>
<h:selectManyCheckbox value="#{usuarioSession.roles}" id="doce" disabled="#{checkView.validarDoc}">
<f:selectItem itemValue="2" itemLabel="Docente"></f:selectItem>
<p:ajax listener="#{checkView.checkBoxDoc()}" update="est, cursos"></p:ajax>
</h:selectManyCheckbox>
<h:selectManyCheckbox value="#{usuarioSession.roles}" id="est" disabled="#{checkView.validarEst}">
<f:selectItem itemValue="3" itemLabel="Estudiante"></f:selectItem>
<p:ajax listener="#{checkView.checkBoxEst()}" update="doce, admin"></p:ajax>
</h:selectManyCheckbox>
</div>
<p:outputPanel rendered="#{checkView.check2 == true}" id="cursos" >
<div class="mb-3">
<h:outputLabel class="form-label">Curso</h:outputLabel>
<h:selectManyCheckbox value="#{usuarioSession.cursos}">
<c:forEach items="#{crearCursoView.listarCurso()}" var="lc">
<f:selectItem itemValue="#{lc}" itemLabel="#{lc.nombre}"></f:selectItem>
</c:forEach>
</h:selectManyCheckbox>
</div>
</p:outputPanel>
Ok, my problem is I can't update a component (cursos) from ajax, I do not really know why.
Here's my code:
Rol
<h:selectManyCheckbox value="#{usuarioSession.roles}" id="admin" disabled="#{checkView.validarAdm}">
<f:selectItem itemValue="1" itemLabel="Administrador"></f:selectItem>
<p:ajax listener="#{checkView.checkBoxAdmin()}" update="est"></p:ajax>
</h:selectManyCheckbox>
<h:selectManyCheckbox value="#{usuarioSession.roles}" id="doce" disabled="#{checkView.validarDoc}">
<f:selectItem itemValue="2" itemLabel="Docente"></f:selectItem>
<p:ajax listener="#{checkView.checkBoxDoc()}" update="est, cursos"></p:ajax>
</h:selectManyCheckbox>
<h:selectManyCheckbox value="#{usuarioSession.roles}" id="est" disabled="#{checkView.validarEst}">
<f:selectItem itemValue="3" itemLabel="Estudiante"></f:selectItem>
<p:ajax listener="#{checkView.checkBoxEst()}" update="doce, admin"></p:ajax>
</h:selectManyCheckbox>
</div>
<p:outputPanel rendered="#{checkView.check2 == true}" id="cursos" >
<div class="mb-3">
<h:outputLabel class="form-label">Curso</h:outputLabel>
<h:selectManyCheckbox value="#{usuarioSession.cursos}">
<c:forEach items="#{crearCursoView.listarCurso()}" var="lc">
<f:selectItem itemValue="#{lc}" itemLabel="#{lc.nombre}"></f:selectItem>
</c:forEach>
</h:selectManyCheckbox>
</div>
</p:outputPanel>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有一个非常常见的问题
rendered =“#{checkview.check2 == true}”
,因为如果未在JSF树中呈现输出panel,则它不会在JSF树中呈现。秘密是始终使用没有渲染
标志的包装组件,以便您始终可以更新包装器元素以使p:oppotepanel
显示和hide。使用下面的示例,然后更新cursoswrapper
而不是furesos
...或使用JSF PassThrough添加
JSF:Rendered
flag到Inner Div。You have a very common problem
rendered="#{checkView.check2 == true}"
because if your outputpanel is not rendered its not in the JSF tree so you can't update it. The secret is to always use a wrapper component that has NOrendered
flag on it so you can always just update that wrapper element to make thep:outputPanel
show and hide. use the example below and updatecursosWrapper
instead ofcursos
...or use JSF passthrough to add
jsf:rendered
flag to the inner DIV.