Java 如何基于p:selectOneRadio创建列表

Java 如何基于p:selectOneRadio创建列表,java,jsf,primefaces,Java,Jsf,Primefaces,我有一个JSF页面,其中包含以下selectOneRadio定义: <p:outputPanel id="customPanel" style="margin-bottom:10px"> <p:selectOneRadio id="customRadio" layout="custom" required="true" > <f:selectItem itemLabel="Número de Documento" itemValue="0"

我有一个JSF页面,其中包含以下selectOneRadio定义:

<p:outputPanel id="customPanel" style="margin-bottom:10px">
   <p:selectOneRadio id="customRadio" layout="custom"  required="true" >
        <f:selectItem itemLabel="Número de Documento" itemValue="0" />
        <f:selectItem itemLabel="Nombre(s)" itemValue="1" />                     
        <f:selectItem itemLabel="Estado" itemValue="2" />   
   </p:selectOneRadio>

   <h:panelGrid columns="3" cellpadding="5">
        <p:radioButton for="customRadio" itemIndex="0" />
              <h:outputLabel for="txtNroDocumento" value="Número de Documento" />
              <p:inputText id="txtNroDocumento" value="#{empleadoMb.empleado.nroDocumento}"/>

              <p:radioButton id="txtNombre" for="customRadio" itemIndex="1" />
              <h:outputLabel for="txtNombre" value="Nombre(s)" />
              <p:inputText />

              <p:radioButton id="txtEstado" for="customRadio" itemIndex="2" />
              <h:outputLabel for="txtEstado" value="Estado" />
              <h:selectOneMenu value="#{empleadoMb.busqueda}">
                 <f:selectItem itemLabel="Seleccionar" itemValue="-1"/>
                 <f:selectItems value="#{empleadoMb.listaEstado}" var="st" itemValue="#{st.idParametro}" itemLabel="#{st.dato}"/>                                
              </h:selectOneMenu>
   </h:panelGrid>
</p:outputPanel>

控制器是一个ManagedBean。我需要知道的是,当我选择一个单选按钮时,如何根据其ID卡、姓名或状态创建员工列表。
我一直在我的支持bean中即兴创作,但它不起作用。

首先,你的selectOneRadio需要一个值和ajax,你的selectOneMenu需要一个id:

<p:selectOneRadio "#{empleadoMb.radioValue}" id="customRadio" layout="custom"  required="true" >
     <f:selectItem itemLabel="Número de Documento" itemValue="0" />
     <f:selectItem itemLabel="Nombre(s)" itemValue="1" />                     
     <f:selectItem itemLabel="Estado" itemValue="2" />  
     <p:ajax listener="#{empleadoMb.radioValueChanged()}" update="selectMenu" />
</p:selectOneRadio>

<h:selectOneMenu id="selectMenu" value="#{empleadoMb.busqueda}">
             <f:selectItem itemLabel="Seleccionar" itemValue="-1"/>
             <f:selectItems value="#{empleadoMb.listaEstado}" var="st" itemValue="#{st.idParametro}" itemLabel="#{st.dato}"/>                                
          </h:selectOneMenu>

很抱歉,我想表示我需要从每个单选按钮(一个用于“Número Documento”/“Nombre”/“Estado”)获取输入。然后我得到:
。此按钮根据从单选按钮中选择的一个标准('Número Documento'/'Nombre'/'Estado')更新表格并查找列表。我真正需要的是得到这些信息。或者如果你有更好的主意,请随意教我。感谢您的时间。如果您的commandButton与输入的形式相同,它应该将它们的值提交给bean,因此您应该能够在GetListOS方法中使用inputfields的值。如果这不能帮助创建一个mcve,它涉及到你的bean和页面中与问题相关的部分,那么现在我只需要知道如何从每个单选按钮中获取这些值。我的意思是,我只需要在一个变量中设置其中一个值,然后我将使用该变量来查找和创建列表。事实上,我知道怎么做,但我需要知道如何在我的jsf/htmlx页面中做到这一点。感谢您的时间和回答。您只需为每个输入设置一个值,就像您为一个inputText所做的那样:
private int radioValue;

public void radioValueChanged(){
// your current value is in the variable radioValue now, you can change your list depending on the value here, the update in the p:ajax will refresh the selectOneMenu after that.
}

//getter + setter for radioValue