myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From M Rather <>
Subject problem with selectItems built using the bean property in addition to a lookup
Date Mon, 24 Dec 2007 17:41:35 GMT

I have a <h:selectOneMenu ... . It has its options populated by 
<f:selectItems value="#{lookupObject.availableOptions...}" />

I addtionally have two <f:selectItem along with it

<f:selectItem itemValue="" itemLabel="Select One Option" />
<f:selectItem itemValue="#{}"

(eventually, the second f:selectItem needs to be rendered optionally.. 
but assume for now that is is needed.

The reason for this is this:

I have a dropdown in a form, its options and values should be :

"" "Select One Option"
"currentId" "Current Selected Option"
"optionOneId" "Available Option 1"
"optionTwoId" "Available Option 2"

If users select 'Select One Option', that delinks the obejct 
relationship with that option (as this field is optional)
If user selects any of the Available Options, then on submit, object is 
linked with that option.
And, if the user does not change the option from 'Current Selected 
Option', then the object retains its existing relationship

In my case,
If a user selects 'Select One Option' or any of other options, the 
submit works fine, including building of relationships.
BUT , IF a user does not change the options, upon submit I get the 
following error:

beanForm:childObject: Validation Error: Value is not valid

I tried to use, 'immediate=true' to skip validation, and even wrote my 
custom validator for the component, (actually, doing nothing in it, 
assuming that will treat it as no error on validations), but I still get 
this error?

Am I doing something wrong here?

Another thing to note is when the form is drawn after submit, the 
'Current Selected Option' is empty and its value is empty. Should I be 
populating this option in any other way? instead of the bean.entity itself?


View raw message