This discussion is archived
2 Replies Latest reply: Dec 5, 2012 2:56 AM by 859967 RSS

selectOneMenu  validation error

859967 Newbie
Currently Being Moderated
Hi,

I am facing h:selectOneMenu validation error which is quite annoying.
I have a Select One Menu and a button near by. When i click on the button, a popup will be displayed and let me choose some items. After doing this, popup will be close and selected items will be inserted to the Select One Menu. (popup is done through javascript, and on closing the popup, i use javascript to insert to the Select One Menu)

From new item list, i can select some of them to shift to another box B. And the error happens at this point, when i select an item to add to box B.

After google around, i found it because the selected items are not in the list (Select One Menu) (according to [this link|http://stackoverflow.com/questions/4566587/jsf-validation-error-value-is-not-valid-for-selectonemenu] .)

Select One Menu must be changed, so that the selected items are not in the list initially. Then how do i resolve this problem? ahh,, the problem happens frequently but not always, perhaps because of the cache

thanks,

Edited by: CardM on Nov 29, 2012 11:18 PM
  • 1. Re: selectOneMenu  validation error
    gimbal2 Guru
    Currently Being Moderated
    Yep, you're doing it wrong. You do it the JSF way or you take a hike. This means you really have to understand how JSF ticks, one of the things that puts people off from using it when they figure out it isn't as easy as mashing some stuff together and staying obliviously ignorant. You can't, you need to really, really, really understand the framework from guts to glory.

    The tricks is to just do not meddle with Javascript yourself; JSF is a stateful framework and maintains server-side state which you are making go out of sync with your manual meddling. If you make changes to the view the changes need to happen both server side and client side. The easiest way to do that is to use the Ajax capabilities of both the core framework but even easier would be to use one of the extension frameworks, such as Primefaces. Whatever you're doing, I'm pretty sure there is a component already built somewhere that does what you want.

    Note that the link to Enterprise Javabeans completely escapes me.
  • 2. Re: selectOneMenu  validation error
    859967 Newbie
    Currently Being Moderated
    thanks,

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points