在JSF中选中另一个单选按钮时显示隐藏的单选按钮
我试图根据UI事件隐藏/显示JSF面板。 更具体地说,我有很多单选按钮, 每个单选按钮都应该存在于自己的面板中。 我需要根据单选按钮单击使隐藏面板可见。在JSF中选中另一个单选按钮时显示隐藏的单选按钮,jsf,jsf-2.2,Jsf,Jsf 2.2,我试图根据UI事件隐藏/显示JSF面板。 更具体地说,我有很多单选按钮, 每个单选按钮都应该存在于自己的面板中。 我需要根据单选按钮单击使隐藏面板可见。 我怎样才能做到这一点?而不是使用CSS属性可见性< /代码>,你应该考虑要么渲染单选按钮-要么不取决于第一个单选按钮的值。< /P> 请记住,您不能更新未渲染的组件,而只能更新其父组件: <h:form> <h:panelGroup id ="grp1"> <h:selectOneRadio
我怎样才能做到这一点?而不是使用CSS属性<代码>可见性< /代码>,你应该考虑要么渲染单选按钮-要么不取决于第一个单选按钮的值。< /P> 请记住,您不能
更新未渲染的组件,而只能更新其父组件:
<h:form>
<h:panelGroup id ="grp1">
<h:selectOneRadio value="#{testController.radio1}">
<f:selectItem itemValue="show" itemLabel="Show next Radio" />
<f:selectItem itemValue="hide" itemLabel="Hide next Radio" />
<f:ajax render="grp2"></f:ajax>
</h:selectOneRadio>
</h:panelGroup>
<h:panelGroup id ="grp2">
<h:selectOneRadio value="#{testController.radio2}" rendered="#{testController.radio1 eq 'show'}">
<f:selectItem itemValue="show" itemLabel="Show next Radio" />
<f:selectItem itemValue="hide" itemLabel="Hide next Radio" />
</h:selectOneRadio>
</h:panelGroup>
</h:form>
<>而不是使用CSS属性<代码>可见性< /代码>,您应该考虑是否使用单选按钮的值,或者根据第一单选按钮的值来呈现单选按钮。
请记住,您不能更新未渲染的组件,而只能更新其父组件:
<h:form>
<h:panelGroup id ="grp1">
<h:selectOneRadio value="#{testController.radio1}">
<f:selectItem itemValue="show" itemLabel="Show next Radio" />
<f:selectItem itemValue="hide" itemLabel="Hide next Radio" />
<f:ajax render="grp2"></f:ajax>
</h:selectOneRadio>
</h:panelGroup>
<h:panelGroup id ="grp2">
<h:selectOneRadio value="#{testController.radio2}" rendered="#{testController.radio1 eq 'show'}">
<f:selectItem itemValue="show" itemLabel="Show next Radio" />
<f:selectItem itemValue="hide" itemLabel="Hide next Radio" />
</h:selectOneRadio>
</h:panelGroup>
</h:form>
<>而不是使用CSS属性<代码>可见性< /代码>,您应该考虑是否使用单选按钮的值,或者根据第一单选按钮的值来呈现单选按钮。
请记住,您不能更新未渲染的组件,而只能更新其父组件:
<h:form>
<h:panelGroup id ="grp1">
<h:selectOneRadio value="#{testController.radio1}">
<f:selectItem itemValue="show" itemLabel="Show next Radio" />
<f:selectItem itemValue="hide" itemLabel="Hide next Radio" />
<f:ajax render="grp2"></f:ajax>
</h:selectOneRadio>
</h:panelGroup>
<h:panelGroup id ="grp2">
<h:selectOneRadio value="#{testController.radio2}" rendered="#{testController.radio1 eq 'show'}">
<f:selectItem itemValue="show" itemLabel="Show next Radio" />
<f:selectItem itemValue="hide" itemLabel="Hide next Radio" />
</h:selectOneRadio>
</h:panelGroup>
</h:form>
<>而不是使用CSS属性<代码>可见性< /代码>,您应该考虑是否使用单选按钮的值,或者根据第一单选按钮的值来呈现单选按钮。
请记住,您不能更新未渲染的组件,而只能更新其父组件:
<h:form>
<h:panelGroup id ="grp1">
<h:selectOneRadio value="#{testController.radio1}">
<f:selectItem itemValue="show" itemLabel="Show next Radio" />
<f:selectItem itemValue="hide" itemLabel="Hide next Radio" />
<f:ajax render="grp2"></f:ajax>
</h:selectOneRadio>
</h:panelGroup>
<h:panelGroup id ="grp2">
<h:selectOneRadio value="#{testController.radio2}" rendered="#{testController.radio1 eq 'show'}">
<f:selectItem itemValue="show" itemLabel="Show next Radio" />
<f:selectItem itemValue="hide" itemLabel="Hide next Radio" />
</h:selectOneRadio>
</h:panelGroup>
</h:form>