myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bart Kummel <bkum...@gmail.com>
Subject Re: Problem with combination of f:selectItems and tr:selectOneChoice...
Date Thu, 08 Apr 2010 11:22:48 GMT
Hi Lukasz,

The error message says it all: JSF is looking for a value "
com.pac5.datamodel.pojos.ris.dictionaries.SlownikRisPracowni@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.feldman@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 <
> antongavazuk@gmail.com> napisał:
>
> > Lukasz,
> >
> > could you verify that your custom converter works with standart
> > h:selectOneMenu component?
> >
> > 2010/4/6 Lukasz Feldman <lukasz.feldman@googlemail.com>
> >
> > > Here is english version:
> > >
> > > WARNING: Could not find selected item matching value "
> > > com.pac5.datamodel.pojos.ris.dictionaries.SlownikRisPracowni@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 <bkummel@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.feldman@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.SlownikRisPracowni@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

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