访问rowselector时重新发布selectOneMenu值

时间:2010-11-05 20:06:56

标签: jsf datatable icefaces

嗨,我有这种情况,我不知道为什么会这样......

我有像这样的选择菜单

<ice:selectOneMenu id="ddlProfesion" value="#{FrmClientes.profesionSeleccionado}" style="width:230px"> 
<f:selectItems value="#{SessionBean1.listaProfesion}"/> 
<f:converter converterId="DefaultSelectItemConverter" /> 
</ice:selectOneMenu> 

项目清单

public List getListaProfesion() { 

if (listaProfesion == null) { 
Session session = HibernateUtil.getSessionFactory().getCurrentSession(); 
session.beginTransaction(); 
listaProfesion = new ArrayList<SelectItem>(); 
List<Profesion> profesionList = session.getNamedQuery("Profesion.findAll").list(); 
for (Profesion c : profesionList) { 
listaProfesion.add(new SelectItem(c, c.getNombre())); 
} 
return listaProfesion; 
} 
return listaProfesion; 
} 

现在我有一个数据表,当我连续点击一个panelPopup时,打开了对象Profesion的数据..

rowSelector中selectionListener的代码是:

 public void seleccionaTerceros(RowSelectorEvent event) {


         Session session = HibernateUtil.getSessionFactory().getCurrentSession();
         session.beginTransaction();

         Query query = session.getNamedQuery("Clientes.findByTercero");
         query.setParameter("tercero", "12332454");
 // I send a parameter value for example

         if (!query.list().isEmpty()) {
            cliente = (Clientes) query.list().get(0);
             profesionSeleccionado=cliente.getProfesionID();
         } else {
             cliente = null;
             profesionSeleccionado=null;
         }

         setMostrarModal(true);

     }

我将profesionSeleccionado设置为objetc的值并且不起作用,我将此代码放在另一个位置,例如托管bean的构造函数或按钮操作......并且它工作...

我已经进行了debbuged,并且看到了getter和atribute的setter两次加入,为什么,我不知道

请我需要一些指导,我是新的...谢谢

pd:用于在selectonemenu中列出对象的转换器代码是

public class DefaultSelectItemConverter implements Converter {


     /**
      * Not explicitly documented.
      *
      * @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext,
      * javax.faces.component.UIComponent, java.lang.String)
      */

     public Object getAsObject(FacesContext fcontext, UIComponent comp, String valueString) {

         List<UIComponent> children = comp.getChildren();
         for (UIComponent child : children) {

             if (child instanceof UISelectItem) {
                 UISelectItem si = (UISelectItem) child;
                 if (si.getValue().toString().equals(valueString)) {
                     return si.getValue();
                 }
             }

             if (child instanceof UISelectItems) {
                 UISelectItems sis = (UISelectItems)child;
                 List<SelectItem> items = (List)sis.getValue();
                 for (SelectItem si : items) {
                     if (si.getValue().toString().equals(valueString)) {
                         return si.getValue();
                     }
                 }
             }
         }
         throw new ConverterException("no conversion possible for string representation: " + valueString);
     }

     /**
      * Not explicitly documented.
      *
      * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext,
      * javax.faces.component.UIComponent, java.lang.Object)
      */
     public String getAsString(FacesContext fcontext, UIComponent comp, Object value) {
         return value.toString();
     }
 }

1 个答案:

答案 0 :(得分:1)

我在本页找到了解决方案

http://jira.icefaces.org/browse/ICE-2297

问题得到解决,在RowSelector

上设置immediate =“false”

:)