Events JSF ajax行为侦听器

Events JSF ajax行为侦听器,events,jsf-2,Events,Jsf 2,我在使用selectOneRadio和面板的渲染器时遇到问题 My cession.xhtml包含以下内容 <p:selectOneRadio id="options" value="#{editionBean.radioProprietaire}"> <f:selectItem itemLabel="Particulier" itemValue="particulier" /> <f:selectItem itemLabel="So

我在使用selectOneRadio和面板的渲染器时遇到问题

My cession.xhtml包含以下内容

    <p:selectOneRadio id="options" value="#{editionBean.radioProprietaire}">
      <f:selectItem itemLabel="Particulier" itemValue="particulier" />
      <f:selectItem itemLabel="Societe" itemValue="societe" />
      <f:ajax listener="#{editionBean.listener}"/>
    </p:selectOneRadio>

    <h:panelGroup rendered="#{editionBean.renderSoc}">...</h:panelGroup>
    <h:panelGroup rendered="#{editionBean.renderPart}">...</h:panelGroup>
我知道方法侦听器是调用的,但是面板不可见,如果有人可以帮助我?

如中所述,您应该将组件包装在UIContainer中,并呈现较大的容器,以便使面板可见:

如中所述,应将组件包装在UIContainer中,并渲染该更大的容器,以使面板可见:

有两个问题

您需要而不是在PrimeFaces组件中

您需要在ajax更新中显式指定JSF组件,以便重新呈现它。使用当前的方法,您基本上没有更新任何内容。对于,应在“渲染”属性和“更新”属性中指定要更新的组件

此外,还有一些效率低下的问题。您根本不需要侦听器方法和那些布尔属性。可以直接在渲染属性中检查单选按钮值

因此,总而言之,这应该做到:

<p:selectOneRadio id="options" value="#{editionBean.radioProprietaire}">
    <f:selectItem itemLabel="Particulier" itemValue="particulier" />
    <f:selectItem itemLabel="Societe" itemValue="societe" />
    <p:ajax update="groups" />
</p:selectOneRadio>

<h:panelGroup id="groups">
    <h:panelGroup rendered="#{editionBean.radioProprietaire == 'societe'}">
        ...
    </h:panelGroup>
    <h:panelGroup rendered="#{editionBean.radioProprietaire == 'particulier'}">
        ...
    </h:panelGroup>
</h:panelGroup>
另见: 有两个问题

您需要而不是在PrimeFaces组件中

您需要在ajax更新中显式指定JSF组件,以便重新呈现它。使用当前的方法,您基本上没有更新任何内容。对于,应在“渲染”属性和“更新”属性中指定要更新的组件

此外,还有一些效率低下的问题。您根本不需要侦听器方法和那些布尔属性。可以直接在渲染属性中检查单选按钮值

因此,总而言之,这应该做到:

<p:selectOneRadio id="options" value="#{editionBean.radioProprietaire}">
    <f:selectItem itemLabel="Particulier" itemValue="particulier" />
    <f:selectItem itemLabel="Societe" itemValue="societe" />
    <p:ajax update="groups" />
</p:selectOneRadio>

<h:panelGroup id="groups">
    <h:panelGroup rendered="#{editionBean.radioProprietaire == 'societe'}">
        ...
    </h:panelGroup>
    <h:panelGroup rendered="#{editionBean.radioProprietaire == 'particulier'}">
        ...
    </h:panelGroup>
</h:panelGroup>
另见:
非常感谢您的回答,但是当我单击Radio按钮时,什么也没有出现…select Radio和面板组的组件是相同的吗?是的,它们在同一个h:Form中注意,中的逗号是无效语法。@BalusC修复了它,有时我会对RichFaces reRender语法感到困惑。非常感谢您的回答,但是当我点击Radio按钮时,什么也没有出现……select Radio和面板组的组件是相同的吗?是的,它们是相同的h:Form注意,中的逗号是无效语法。@BalusC修复了它,有时我会对RichFaces reRender语法感到困惑。我可以更改我的文件editionBean吗?或web.xml或其他配置文件?您只需删除未使用的属性和未使用的侦听器方法。是的,我的bean只包含属性及其getter和setter。我无法发布我的代码,因为我需要10个声誉^此处,您可以看到我的代码。在您的视图中,所有人都在做什么?移除它们。此外,请清楚地描述您的具体问题。上面的答案应该可以解决您的问题,但您从未明确确认或拒绝该解决方案。我可以更改我的文件editionBean吗?或web.xml或其他配置文件?您只需删除未使用的属性和未使用的侦听器方法。是的,我的bean只包含属性及其getter和setter。我无法发布我的代码,因为我需要10个声誉^此处,您可以看到我的代码。在您的视图中,所有人都在做什么?移除它们。此外,请清楚地描述您的具体问题。上述答案应该可以解决您的问题,但您从未明确确认或否认解决方案。
<p:selectOneRadio id="options" value="#{editionBean.radioProprietaire}">
    <f:selectItem itemLabel="Particulier" itemValue="particulier" />
    <f:selectItem itemLabel="Societe" itemValue="societe" />
    <p:ajax update="groups" />
</p:selectOneRadio>

<h:panelGroup id="groups">
    <h:panelGroup rendered="#{editionBean.radioProprietaire == 'societe'}">
        ...
    </h:panelGroup>
    <h:panelGroup rendered="#{editionBean.radioProprietaire == 'particulier'}">
        ...
    </h:panelGroup>
</h:panelGroup>