Validation Error: Value is not valid with selectManyListbox

UI Components for JSF
Post Reply
rym
Posts: 23
Joined: 22 Jun 2011, 16:46

01 Aug 2011, 10:00

Hello,
I'am using JSF2.0/primefaces,

I have an error that I can not understand it's cause, I have 2 components selectOneMenu and selectManyListbox ,when I choose an option from the first the second is filled ,the problem is when I choose an option from the second the following error appear:

f1:env1 : Validation Error: Value is not valid

JSF :

Code: Select all

 <h:outputLabel value="Platform:" /> 
          <h:selectOneMenu value="#{FMTools.platform}" id="platforms">
           <f:selectItem itemLabel="-- Select Plateform-- " itemValue="0"/> 
           <f:selectItems value="#{FMTools.getMyListPaltform()}" />
           <f:ajax listener="#{FMTools.UpdateChangeEnvironment()}" render="env1" />
       </h:selectOneMenu>


     <h:selectManyListbox   value="#{FMTools.selectedEnvironment}"  id="env1" size="3">
         <f:selectItem itemLabel="-- Select Environment -- " itemValue="0"/> 
         <f:selectItems value="#{FMTools.getMyListEnvironment()}" />
     </h:selectManyListbox>   //when I choose an environment the error appear

My BEAN:

Code: Select all

private List<SelectItem> MyListEnv;
private ArrayList<String> selectedEnvironment;


public List<SelectItem> getMyListEnvironment()
 {
   if (MyListEnv == null) {
    MyListEnv = new ArrayList<SelectItem>();
    for (String val : this.getMyListEnvironmentByPlatform()) {
    MyListEnv.add(new SelectItem(val));
    }
  }
     return MyListEnv;
 }

Thank you

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

01 Aug 2011, 10:02

Use view scope and cache the results of getMyListEnvironment in it's own property.

rym
Posts: 23
Joined: 22 Jun 2011, 16:46

01 Aug 2011, 10:29

Hello,
thank you for the reply,
I have tried view scope but other errors appeared :( ,
I don't know why this error appear I have used before selectManyListbox and I have retrieved the selected items without any problem!
Last edited by rym on 01 Aug 2011, 11:24, edited 1 time in total.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

01 Aug 2011, 11:03

This is a common case, you need to make sure, the second listbox items contain the submitted value. Otherwise for security JSF does not allow the submitted value.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests