You select one bean is request scope. The list of items is populated
only during your first action. That mean when user select an item and
submit the form, the bean is recreated (request scope) with an empty
list (your own initalization code) and jsf can not find a selectItem
corresponding to the one you have choosen.

For details, see sun jsf javadoc, found the doc in 5 minutes :)

http://java.sun.com/javaee/javaserverfaces/1.0/docs/api/javax/faces/component/UISelectOne.html

void  validate(javax.faces.context.FacesContext context)
           In addition to the standard validation behavior inherited
from UIInput, ensure that any specified value is equal to one of the
available options.

Thrust JSF, if it tells you there is a validation, that obviously mean
you value didn't pass validation.

So no, jsf is not that hard :) But like every framework, sometimes a
problem can get you crazy when you try for hours to find the reason that
is just below you noise.

btw: <h:messages showDetails="true"/> is your friend :)

So you solution, always populate your list correctly.


Behrang Saeedzadeh a écrit :
> Hi,
>
> <em>
>
> I think in a day or two I have to rest in a hospital because JSF is
> almost making me schizophrenic! ;-)
>
> </em>
>
> I have uploaded the source/binary of the sample app I am working on it:
>
>   http://files.myopera.com/behrangsa/files/JSF-HOWTO.zip
>
> Just copy the exploded directory to Tomcat's webapps directory and it
> should run with no problems.
>
> Click on the h:selectOneMenu link, and then on the Show Items link.
> Then select an item from the menu and press the Select link.
>
> I thought this is gonna set the selectedItemId in the backing bean and
> show it when the page redisplays. But instead, a validation error
> occurs. The version that uses t:saveState doesn't work as well.
>
> Any ideas how can I make this work, without falling back to the
> session scope?
>
> <em>
>
> What I was able to accomplish in Struts and WebWork, just the same day
> I read a tutorial about each one of them, has left me scratch my head
> for more than a week. Yes, I could use the session scope, but I can't
> ask my customers to restart their app server once an hour! Nor do they
> have the resources to buy a supercomputer from Cray!
>
> </em>
>
>
> P.S: Does anybody know if it's just as difficult (or as inefficient)
> to implement this use-case in ASP.NET?
>

Reply via email to