2017-06-26 2 views
0

私は、次のselectOneRadio定義して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です。私が知る必要があるのは、ラジオボタンを1つ選択すると、その人のIDカード、名前、またはステータスに基づいて従業員のリストを作成する方法です。 私はバッキング・ビーンで即興をしてきましたが、うまくいきません。

答えて

0

すべてのselectOneRadioはIDを値とAjaxを必要とし、あなたのselectOneMenuの初:あなたの豆で

<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> 

あなたがリスナーにあなたのリストを処理することができます:

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 
+0

ごめんなさい私は、すべてのラジオボタン(「NúmeroDocumento/Nombre」/「Estado」のためのもの)からのインプットを得る必要があることを表現したかったのです。次に、私は: ''を取得しました。このボタンは、テーブルを更新し、ラジオボタンから選択された1つの基準( 'NúmeroDocumento'/'Nombre'/'Estado')に基づいてリストを検索します。私が本当に必要とするのは、それらの入力を得ることです。または、あなたが良いアイデアを持っている場合は、私に教えてください。御時間ありがとうございます。 –

+0

commandButtonが入力と同じ形式の場合は、その値をBeanに提出する必要があります。そのため、getListaEmpleadosメソッドの入力フィールドの値を処理できるはずです。それがあなたのbeanの部分と質問に関連するページを含むmcveを作成するのに役立たない場合https://stackoverflow.com/help/mcve – lastresort

+0

これまでのところ、私はそれらの値をどのように得ることができるかを知る必要がありますすべてのラジオボタンから。つまり、変数にこれらの値の1つを設定するだけで、その変数を使用してリストを検索して作成します。 Logically私は方法を知っていますが、私は私のjsf/htmlxページでそれをどうやって行うことができるか知る必要があります。あなたの時間とあなたの答えをありがとう。 –

関連する問題