Hi I’ve this situation and I dont know why it’s happening..
I have a selectonemenu like this
<ice:selectOneMenu id="ddlProfesion" value="#{FrmClientes.profesionSeleccionado}" style="width:230px">
<f:selectItems value="#{SessionBean1.listaProfesion}"/>
<f:converter converterId="DefaultSelectItemConverter" />
</ice:selectOneMenu>
the list of items
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;
}
now I have a datatable and when I click in a row a panelPopup open with the data of the object Profesion..
the code of the selectionListener in the rowSelector is this:
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);
}
I set profesionSeleccionado to the Value of the objetc and doesnt work, I put this code in another location, like the constructor of the managed bean or in a button action.. and IT WORKS…
I have debbuged and see that the getter and the setter of the atribute are accesed twice, why, i dont know
please I need some guide, I’am new with this.. Thanks
pd: the code of the converter used to list objects in the selectonemenu is this
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();
}
}
I found the solution in this page
http://jira.icefaces.org/browse/ICE-2297
the problem was corrected putting immediate=”false” on the RowSelector
🙂