Jsf 如何将值从托管bean设置到selectradiobutton中?

Jsf 如何将值从托管bean设置到selectradiobutton中?,jsf,primefaces,Jsf,Primefaces,我有一个datatable,其中有一列带有selectoneradio,所以如果我的数据库中有收音机,我应该打开收音机。因此,我恢复了数据,但我不知道当我的用户使用表格查看页面时,如何告诉selectoneradio按钮处于打开状态。以下是我表格中的代码: 下面是我的支持bean提供给我的数据表的方法: public String consultarPerfil(int id, String perfil) { this.setId(id); this.setPerfil(p

我有一个datatable,其中有一列带有selectoneradio,所以如果我的数据库中有收音机,我应该打开收音机。因此,我恢复了数据,但我不知道当我的用户使用表格查看页面时,如何告诉selectoneradio按钮处于打开状态。以下是我表格中的代码:


下面是我的支持bean提供给我的数据表的方法:

public String consultarPerfil(int id, String perfil) {
    this.setId(id);
    this.setPerfil(perfil);
    try {
        List<Perfiles_Secciones> list = getPerfiles_SeccionesService().getPerfiles_Seccion(id);
        int i = 0;
        for(SeccionesDTO seccionDTO : seccionesList) {
            for(Perfiles_Secciones ps : list) {
                if (seccionDTO.getId() == ps.getId_seccion()) {                            
                    System.out.println(seccionDTO.getId() + " - " + ps.getId_seccion());
                    seccionDTO.setNivel(ps.getNivel()); 
                }
                i++;
            }
            i = 0;
        }
        for(SeccionesDTO seccionDTO : seccionesList) {
            System.out.println(seccionDTO.getNivel());
        }
    } catch (Exception ex) {
        Logger.getLogger(PerfilesManagedBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    return CONSULTAR_PERFIL;
}
public String consultarPerfil(int-id,String-perfil){
这个.setId(id);
这个.setPerfil(perfil);
试一试{
List List=getPerfiles\u SeccionesService().getPerfiles\u Seccion(id);
int i=0;
for(SeccionesDTO seccionDTO:seccionesList){
用于(性能安全:列表){
如果(secciondo.getId()==ps.getId_seccion()){
System.out.println(seccionDTO.getId()+“-”+ps.getId\u seccion());
secciondo.setNivel(ps.getNivel());
}
i++;
}
i=0;
}
for(SeccionesDTO seccionDTO:seccionesList){
System.out.println(seccionDTO.getNivel());
}
}捕获(例外情况除外){
Logger.getLogger(PerfilesManagedBean.class.getName()).log(Level.SEVERE,null,ex);
}
返回领事馆;
}

要从我的托管bean中输入selectoneradio,我需要做什么?

确保
secciones。nivel
值与单选按钮中的一些
itemValue
s项匹配。一些匹配,但它们仍然没有打开它们。您确定
secciones吗?nivel
字符串,右边是值是
等于(seccionesNivel)
?我在我的xhtml secciones.nivel上打印,它看起来是空的,这很奇怪,因为根据我的方法consultarPerfil,有值???现在你知道为什么这不起作用了。试着找出问题的根源。