0

In my ManagedBean, I have the following property:

@ManagedBean @RequestScoped public class MrBean { ... private long[] IDs; private List<Item> items; ... } 

In my .xhtml file, I have the following select many box:

<h:selectManyListbox label="abc" id="abc" size="5" value="#{MrBean.IDs}"> <f:selectItems value="#{MrBean.items}" var="i" itemLabel="#{i.name}" itemValue="#{i.id}" /> </h:selectManyListbox> <h:message styleClass="errorMsg" for="abc" /> 

The id of my items are long numbers. Hence, I expected that I would get a list of IDs chosen. However, when I submit the form, abc: Validation Error: Value is not valid appears in the message part for my list box.

Can someone please tell what I have done wrong here?

Best regards, James Tran

1
  • Can you post the full stacktrace? Commented Oct 15, 2011 at 16:57

1 Answer 1

1

You will get this validation error when the selected item(s) doesn't match any of the available items during processing the form submit.

As your bean is request scoped, you need to ensure that you create exactly the same List<Item> in bean's (post)constructor as it was when the form is been displayed. If that's not possible because the contents of the list depends on a previous action, then you need to put the bean in the view scope.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.