myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukasz Feldman <lukasz.feld...@googlemail.com>
Subject Problem with combination of f:selectItems and tr:selectOneChoice...
Date Mon, 05 Apr 2010 22:21:32 GMT
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.SlownikRisPracowni@1b3114" w
CoreSelectOneChoice[UIXEditableFacesBeanImpl, id=j_id213]

Has anyone idea what is going on?

BR,

Lukasz

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message