更新条件渲染表单的字段 [英] update fields of conditionally rendered form

查看:129
本文介绍了更新条件渲染表单的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,我想有条件地渲染form2.这与另一个form1的ajax更新事件发生冲突,该事件应触发form2的呈现.

my problem is, that I want to render form2 conditionally. This collides with a ajax update event of another form1, which should trigger the rendering of form2.

<h:form id="form1">
    <h:selectOneMenu id="selectedGroupId" label="#{msgs.group_group}" value="#{groupBean.selectedGroupId}">
        <p:ajax event="change" listener="#{groupBean.selectGroupEvent}" update=":form1"/>
        <f:selectItems value="#{groupBean.availableGruppen}" />
    </h:selectOneMenu>
</h:form>

<h:form id="form2" rendered="#{not empty groupBean.groupDto}">
  <p:panelGrid id="groupEditGrid">  
    ...
  </p:panelGrid>
</h:form>

有没有一种方法可以将渲染条件不放在form2的组件中?

Is there a way of doing this without putting the render condition inside a component of form2?

谢谢
乔尼

推荐答案

您无法更新不在页面上的组件.但是您可以将表单包装为不是有条件地呈现的h:panelGroup,并改为更新包装器.

You cannot update a component that is not on your page. But you could wrap your form in a h:panelGroup that is not rendered contitionally and update the wrapper instead.

示例:

<h:form id="form1">
    <h:selectOneMenu id="selectedGroupId" label="#{msgs.group_group}" 
                     value="# {groupBean.selectedGroupId}">
        <p:ajax event="change" listener="#{groupBean.selectGroupEvent}"
                update=":formWrapper"/>
        <f:selectItems value="#{groupBean.availableGruppen}" />
    </h:selectOneMenu>
</h:form>

<h:panelGroup id="formWrapper>
  <h:form id="form2" rendered="#{not empty groupBean.groupDto}">
    <p:panelGrid id="groupEditGrid">  
      ...
    </p:panelGrid>
  </h:form>
</h:panelGroup>

这篇关于更新条件渲染表单的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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