Jsf 更改radiobutton时有条件地渲染其他组件

Jsf 更改radiobutton时有条件地渲染其他组件,jsf,radio-button,jsf-1.2,conditional-rendering,Jsf,Radio Button,Jsf 1.2,Conditional Rendering,如果选择了单选按钮,我试图显示菜单。为此,我正在使用渲染属性 型号: private int type; // +getter+setter 视图: 当我检查A时,什么也看不出来。我怎样才能做到这一点呢?通常,你会为此而使用ajax,但由于你显然是在使用JSF 1.x,它缺乏ajax的想象力,只要你不想引入一个支持ajax的组件库,你就会求助于“普通”HTML/JS。其中一种方法就是点击单选按钮直接提交表单 <h:form> <h:selectOneRadio v

如果选择了单选按钮,我试图显示菜单。为此,我正在使用渲染属性

型号:

private int type; // +getter+setter
视图:



当我检查A时,什么也看不出来。我怎样才能做到这一点呢?

通常,你会为此而使用ajax,但由于你显然是在使用JSF 1.x,它缺乏ajax的想象力,只要你不想引入一个支持ajax的组件库,你就会求助于“普通”HTML/JS。其中一种方法就是点击单选按钮直接提交表单

<h:form>
    <h:selectOneRadio value="#{bean.type}" onclick="this.form.submit()">
        <f:selectItem itemLabel="A" itemValue="1"/>
        <f:selectItem itemLabel="B" itemValue="2"/>
    </h:selectOneRadio>
</h:form>
<h:form id="formMention">
    <h:selectOneMenu ... rendered="#{bean.type == 1}">
        <f:selectItems ... />
    </h:selectOneMenu>
</h:form>


谢谢您的回答。我尝试了这个代码,但是页面根本没有显示。我注意到问题在于f:ajax。这可能与我正在使用的JSF版本有关。(我使用的是1.2)?确实如此。没有人会想到现在会有人使用JSF1.x,因为它在5年多前已经升级到JSF2.0,并且已经下线三年了。因此,您最好始终明确指定问题中使用的JSF版本。我会更新答案。
<h:form>
    <h:selectOneRadio value="#{bean.type}" onclick="this.form.submit()">
        <f:selectItem itemLabel="A" itemValue="1"/>
        <f:selectItem itemLabel="B" itemValue="2"/>
    </h:selectOneRadio>
</h:form>
<h:form id="formMention">
    <h:selectOneMenu ... rendered="#{bean.type == 1}">
        <f:selectItems ... />
    </h:selectOneMenu>
</h:form>