Thanks for your suggestion. To be honest I have found a solution based on object without using such a tricks like id propoerty of the object. This was strictly related to the fact, I have below related Hibernate POJOs and I would like to stay with strictly related objects. But returning back to the soution. It is based on the simple rule that I have to hardcore somehow comparision of the object instances such as "com.pac5.datamodel.pojos.ris. dictionaries.slownikrispraco...@1b3114" in selectitem list and konsolaadmina. risAparat.slownikRisPracowni:
(...) public void ustawRisAparat(ValueChangeEvent event) { SlownikRisPracowni pracownia = new SlownikRisPracowni(); risAparat = (SlownikRisAparatow) event.getNewValue(); DetachedCriteria criteria = DetachedCriteria.forClass(SlownikRisPracowni.class); criteria.setFetchMode("slownikRisAparatows", FetchMode.DEFAULT).createAlias("slownikRisAparatows", "aparat").add(Restrictions.eq("aparat.id", risAparat.getId())); List<SlownikRisPracowni> listaPracowni = new RisPracowniSlownikDAO().findByCriteria(criteria); if (listaPracowni.size() > 0) { pracownia = listaPracowni.get(0); FacesContext facesContext = FacesContext.getCurrentInstance(); Application application = facesContext.getApplication(); ValueBinding binding = application.createValueBinding("#{slownikibb}"); SlownikiSelectItems slownikibb = (SlownikiSelectItems) binding.getValue(facesContext); for (SelectItem selektor : slownikibb.getRisPracownieSlownik()) { SlownikRisPracowni pracowniaFromSelektor = (SlownikRisPracowni) selektor.getValue(); if (pracowniaFromSelektor.getId().equals(pracownia.getId())) { risAparat.setSlownikRisPracowni(pracowniaFromSelektor); } } } } (...) public class RisPracowniReadWriteConverter implements Converter { private Logger logger = Logger.getLogger("com.pac5"); public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) { if (arg2.equals(null)) { return null; } FacesContext facesContext = FacesContext.getCurrentInstance(); Application application = facesContext.getApplication(); ValueBinding binding = application.createValueBinding("#{slownikibb}"); SlownikiSelectItems slownikibb = (SlownikiSelectItems) binding.getValue(facesContext); for (SelectItem selektor : slownikibb.getRisPracownieSlownik()) { SlownikRisPracowni pracowniaFromSelektor = (SlownikRisPracowni) selektor.getValue(); if (pracowniaFromSelektor.toString().equals(arg2)) { return (Object) pracowniaFromSelektor; } } return null; } public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) { if (arg2==null) { return ""; } SlownikRisPracowni pracownia = (SlownikRisPracowni) arg2; return Long.toString(pracownia.getId()); } } 2010/4/8 Bart Kummel <bkum...@gmail.com> > Hi Lukasz, > > The error message says it all: JSF is looking for a value " > com.pac5.datamodel.pojos.ris.dictionaries.slownikrispraco...@1b3114", > which > is an Object of class SlownikRisPracowni. The getRisPracownieSlownik() > method that is used to fill the <tr:selectOneChoice> with items returns a > List of SelectItems, where the value of each SelectItem is the ID of a > SlownikRisPracowni > object. So I think if you change the > value="#{konsolaadmina.risAparat.slownikRisPracowni}" > expression in your <tr:selectOneChoice> to something like > value="#{konsolaadmina.risAparat.slownikRisPracowni.id}" > it will work. In other words: the value expression of your <tr:selectItem> > should be of the same type as the values in your list. > > Regarding the "WARNING: FacesMessage(s) have been enqueued, but may not > have > been displayed." error: it seems you don't have a message(s) component on > your page. You should add one, otherwise JSF doesn't have a way to display > error messages. > > Hop this helps! > Best regards, > Bart > > 2010/4/6 Lukasz Feldman <lukasz.feld...@googlemail.com> > > > Hmmm... Now I have xhtml like this: > > > > (...) > > <h:selectOneMenu > > partialTriggers="slownikRisAparatow" > > actionListener="#{konsolaadmina.ustawRisAparat}" > > value="#{konsolaadmina.risAparat.slownikRisPracowni}" > > label="w pracowni"> > > <f:selectItems value="#{slowniki.risPracownieSlownik}"/> > > <f:converter converterId="risPracowniReadWriteConverter"/> > > </h:selectOneMenu> > > (...) > > > > It goes without saying that my PPR mechanism is not working properly > which > > eliminate this as a solution. But to be honest I can see somekind of > > different behavior here. I can see some chosen value for selectonemenu > but > > it is not chosen properly. Additionally I cannot walk between pages > because > > of validation errror: > > > > INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been > > displayed. > > sourceId=konsolaadminaform:tab04:j_id213[severity=(ERROR 2), summary=(w > > pracowni: Validation Error: Value is not valid), detail=(w pracowni: > > Validation Error: Value is not valid)] > > > > BR, > > > > Lukasz > > > > W dniu 6 kwietnia 2010 18:05 użytkownik Anton Gavazuk < > > antongava...@gmail.com> napisał: > > > > > Lukasz, > > > > > > could you verify that your custom converter works with standart > > > h:selectOneMenu component? > > > > > > 2010/4/6 Lukasz Feldman <lukasz.feld...@googlemail.com> > > > > > > > Here is english version: > > > > > > > > WARNING: Could not find selected item matching value " > > > > com.pac5.datamodel.pojos.ris.dictionaries.slownikrispraco...@1b3114" > > in > > > * > > > > CoreSelectOneChoice*[*UIXEditableFacesBeanImpl*, id=j_id213] > > > > I have found same error here but still I am not sure what should I > do: > > > > http://old.nabble.com/af:selectOneChoice-td16572647.html > > > > > > > > BR, > > > > > > > > Lukasz > > > > > > > > 2010/4/6 Bart Kummel <bkum...@gmail.com> > > > > > > > > > Hi Lukasz, > > > > > > > > > > I don't understand the error message, it is not in English. Can you > > > > > configure your appserver to generate English error messages? > > > > > > > > > > Best regards, > > > > > Bart > > > > > > > > > > 2010/4/6 Lukasz Feldman <lukasz.feld...@googlemail.com> > > > > > > > > > > > Hi, > > > > > > > > > > > > I have some challenging problem which makes me a little nervouse > > > since > > > > I > > > > > > have started to solve it few days ago. I want to combine > > > f:selectItems > > > > > with > > > > > > tr:selectOneChoice. Here is code snippet: > > > > > > > > > > > > something.xhtml: > > > > > > ------------------------- > > > > > > (...) > > > > > > <tr:selectOneChoice > > > > > > partialTriggers="slownikRisAparatow" > > > > > > actionListener="#{konsolaadminabb.ustawRisAparat}" > > > > > > value="#{konsolaadmina.risAparat.slownikRisPracowni}" > > > > > > label="w pracowni"> > > > > > > <f:selectItems value="#{slownikibb.risPracownieSlownik}"/> > > > > > > <f:converter converterId="risPracowniReadWriteConverter"/> > > > > > > </tr:selectOneChoice> > > > > > > (...) > > > > > > > > > > > > konsolaadminabb.java: > > > > > > --------------------------------- > > > > > > (...) > > > > > > public void ustawRisAparat(ValueChangeEvent event) { > > > > > > risAparat = (SlownikRisAparatow) event.getNewValue(); > > > > > > DetachedCriteria criteria = > > > > > > DetachedCriteria.forClass(SlownikRisPracowni.class); > > > > > > criteria.setFetchMode("slownikRisAparatows", > > > > > > FetchMode.DEFAULT).createAlias("slownikRisAparatows", > > > > > > "aparat").add(Restrictions.eq("aparat.id", risAparat.getId())); > > > > > > risAparat.setSlownikRisPracowni(new > > > > > > RisPracowniSlownikDAO().findByCriteria(criteria).get(0)); > > > > > > (...) > > > > > > slownikibb.java: > > > > > > ---------------------- > > > > > > (...) > > > > > > public List<SelectItem> getRisPracownieSlownik() { > > > > > > List selectItemList = new ArrayList(); > > > > > > for (SlownikRisPracowni pracownia : > > > > > > slownikiService.zaladujRisPracowniSlownik()) { > > > > > > selectItemList.add(new > > > > > > SelectItem(Long.toString(pracownia.getId()), > > > > > > pracownia.getNazwaPracowni())); > > > > > > } > > > > > > return selectItemList; > > > > > > } > > > > > > (...) > > > > > > risPracowniReadWriteConverter: > > > > > > ----------------------------------------------- > > > > > > public class RisPracowniReadWriteConverter implements Converter { > > > > > > > > > > > > private Logger logger = Logger.getLogger("com.pac5"); > > > > > > > > > > > > public Object getAsObject(FacesContext arg0, UIComponent arg1, > > > > String > > > > > > arg2) { > > > > > > if (arg2.equals(null)) { > > > > > > return null; > > > > > > } > > > > > > return (Object) new > RisPracowniSlownikDAO().findById(arg2); > > > > > > } > > > > > > > > > > > > public String getAsString(FacesContext arg0, UIComponent arg1, > > > > Object > > > > > > arg2) { > > > > > > > > > > > > if (arg2==null) { return ""; } > > > > > > SlownikRisPracowni pracownia = new > > > > > > RisPracowniSlownikDAO().findById(arg2.toString()); > > > > > > return Long.toString(pracownia.getId()); > > > > > > } > > > > > > > > > > > > As a result of this I have a problem like this: > > > > > > > > > > > > 2010-04-05 23:10:35 org.apache.myfaces. > > > > > > trinidadinternal.renderkit.core.xhtml.SimpleSelectOneRenderer > > > > > > _getSelectedIndex > > > > > > WARNING: Nie znaleziono wybranego elementu zgodnego z wartością > > > > > > > > "com.pac5.datamodel.pojos.ris.dictionaries.slownikrispraco...@1b3114 > > > " > > > > w > > > > > > CoreSelectOneChoice[UIXEditableFacesBeanImpl, id=j_id213] > > > > > > > > > > > > Has anyone idea what is going on? > > > > > > > > > > > > BR, > > > > > > > > > > > > Lukasz > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > ___________________________________________________________ > > > > > Bart Kummel > > > > > > > > > > Author of the book "Apache MyFaces 1.2 Web Application Development" > > > > > See http://tinyurl.com/am12wad > > > > > > > > > > > > > > > > > > -- > ___________________________________________________________ > Bart Kummel > > Author of the book "Apache MyFaces 1.2 Web Application Development" > See http://tinyurl.com/am12wad >