selectonemenuitem problems Value is not a valid option

2006-07-10 Thread sarma

Hi,
   I am working with two selectOneListBox  in jsf
   If I selected one item in first list box the corresponding values(from
the database (setting that values to preparedstatement))
must displayed in second list box  
   For that I used value change listener .  
   When I am submitting this form   I  am getting an error 

 cpuids: Value is not a valid option.
  
   This is my code.
This is jsp code.

 h:outputText value=SelectHOST   //th
   h:panelGroup
 h:selectOneMenu id=hostids 
value=#{HRselforeachcpuanduser.host}
  
valueChangeListener=#{HRselforeachcpuanduser.hostSelection}
onchange=submit();immediate=true required=true
 f:selectItem itemValue= itemLabel=/
 f:selectItems 
value=#{HRselforeachcpuanduser.hosts}/ 
   /h:selectOneMenu
  h:message for=hostids style=color:red/
 /h:panelGroup br
 h:outputText value=SelectCPU /
 h:panelGroup
   h:selectOneMenu id=cpuids 
value=#{HRselforeachcpuanduser.cpuid} 
   f:selectItems 
value=#{HRselforeachcpuanduser.cpuids}/   
   /h:selectOneMenu
   h:message for=cpuids style=color:red/
/h:panelGroup


// this is backing bean code 

Corresponding java code
// this is for value change listener
   
public void hostSelection(ValueChangeEvent e) { 
  FacesContext context = FacesContext.getCurrentInstance(); 
  hostid=(String) e.getNewValue();
  getCpuids(); 
  context.renderResponse(); 
 }  
//this is for  host select 

public Map getHosts(){
try{
  openConnection();
  selhostnames=new HashMap(); 
  String str=select distinct hostid from  system_cpu; 
  st=con.createStatement(); 
  rs=st.executeQuery(str);  
  
  while(rs.next()){
hostname=rs.getString(hostid);
System.out.println(hostname);
selhostnames.put(hostname,hostname);
  }
  return selhostnames;
}

public String getHost(){ 
return hostselected; 
  } 
  public void setHost(String hostselected){ 
this.hostselected = hostselected; 
  }

//this is for  cpu  selection 
public Map getCpuids(){
   try{
 
 if(hostid==null){
 System.out.println(if it is null);  // imp  note
 return selcpunames;
 }
  openConnection();
  String str=select distinct cpuid from system_cpu where hostid=?;
  System.out.println(setting cpuids from host);
  ps=con.prepareStatement(str); 
  ps.setString(1,hostid);
  ps.execute();
  rs=ps.getResultSet(); 
  while(rs.next()){
cpuname=rs.getString(cpuid);
System.out.println(cpuname);
selcpunames.put(cpuname,cpuname);
  }
  return selcpunames;
   }   


public void setCpuid(String cpuid){
  this.cpuid=cpuid;
}
public String getCpuid(){
  
  return cpuid;
}



When I am running 
If its  null//in tomcat

And  

cpuids: Value is not a valid option.

What is the problem with my code please tell  and  what to change  

With regards
Shannu sarma
-- 
View this message in context: 
http://www.nabble.com/selectonemenuitem-problems--Value-is-not-a-valid-option-tf1917733.html#a5249864
Sent from the MyFaces - Users forum at Nabble.com.



Re: selectonemenuitem problems Value is not a valid option

2006-07-10 Thread Volker Weber

Hi,

the value of f:selectItems must be a array of SelectItem.

you shoud have:

public SelectItem[] getHosts() {
...
}

regards,
 Volker

2006/7/10, sarma [EMAIL PROTECTED]:


Hi,
   I am working with two selectOneListBox  in jsf
   If I selected one item in first list box the corresponding values(from
the database (setting that values to preparedstatement))
must displayed in second list box
   For that I used value change listener .
   When I am submitting this form   I  am getting an error

 cpuids: Value is not a valid option.

   This is my code.
This is jsp code.

 h:outputText value=SelectHOST   //th
   h:panelGroup
 h:selectOneMenu id=hostids
value=#{HRselforeachcpuanduser.host}
  
valueChangeListener=#{HRselforeachcpuanduser.hostSelection}
onchange=submit();immediate=true required=true
 f:selectItem itemValue= itemLabel=/
 f:selectItems 
value=#{HRselforeachcpuanduser.hosts}/
   /h:selectOneMenu
  h:message for=hostids style=color:red/
 /h:panelGroup br
 h:outputText value=SelectCPU /
 h:panelGroup
   h:selectOneMenu id=cpuids 
value=#{HRselforeachcpuanduser.cpuid} 
   f:selectItems value=#{HRselforeachcpuanduser.cpuids}/
   /h:selectOneMenu
   h:message for=cpuids style=color:red/
/h:panelGroup


// this is backing bean code

Corresponding java code
// this is for value change listener

public void hostSelection(ValueChangeEvent e) {
  FacesContext context = FacesContext.getCurrentInstance();
  hostid=(String) e.getNewValue();
  getCpuids();
  context.renderResponse();
 }
//this is for  host select

public Map getHosts(){
try{
  openConnection();
  selhostnames=new HashMap();
  String str=select distinct hostid from  system_cpu;
  st=con.createStatement();
  rs=st.executeQuery(str);

  while(rs.next()){
hostname=rs.getString(hostid);
System.out.println(hostname);
selhostnames.put(hostname,hostname);
  }
  return selhostnames;
}

public String getHost(){
return hostselected;
  }
  public void setHost(String hostselected){
this.hostselected = hostselected;
  }

//this is for  cpu  selection
public Map getCpuids(){
   try{

 if(hostid==null){
 System.out.println(if it is null);  // imp  note
 return selcpunames;
 }
  openConnection();
  String str=select distinct cpuid from system_cpu where hostid=?;
  System.out.println(setting cpuids from host);
  ps=con.prepareStatement(str);
  ps.setString(1,hostid);
  ps.execute();
  rs=ps.getResultSet();
  while(rs.next()){
cpuname=rs.getString(cpuid);
System.out.println(cpuname);
selcpunames.put(cpuname,cpuname);
  }
  return selcpunames;
   }


public void setCpuid(String cpuid){
  this.cpuid=cpuid;
}
public String getCpuid(){

  return cpuid;
}



When I am running
If its  null//in tomcat

And

cpuids: Value is not a valid option.

What is the problem with my code please tell  and  what to change

With regards
Shannu sarma
--
View this message in context: 
http://www.nabble.com/selectonemenuitem-problems--Value-is-not-a-valid-option-tf1917733.html#a5249864
Sent from the MyFaces - Users forum at Nabble.com.




RE: selectonemenuitem problems Value is not a valid option

2006-07-10 Thread Julian Ray
Have you tried the selectManyPicklist from the sandbox? Works like a charm!
 

-Original Message-
From: sarma [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 10, 2006 7:16 AM
To: users@myfaces.apache.org
Subject: selectonemenuitem problems Value is not a valid option


Hi,
   I am working with two selectOneListBox  in jsf
   If I selected one item in first list box the corresponding values(from
the database (setting that values to preparedstatement))
must displayed in second list box  
   For that I used value change listener .  
   When I am submitting this form   I  am getting an error 

 cpuids: Value is not a valid option.
  
   This is my code.
This is jsp code.

 h:outputText value=SelectHOST   //th
   h:panelGroup
 h:selectOneMenu id=hostids 
value=#{HRselforeachcpuanduser.host}

valueChangeListener=#{HRselforeachcpuanduser.hostSelection}
onchange=submit();immediate=true required=true
 f:selectItem itemValue= itemLabel=/
 f:selectItems
value=#{HRselforeachcpuanduser.hosts}/ 
   /h:selectOneMenu
  h:message for=hostids style=color:red/
 /h:panelGroup br
 h:outputText value=SelectCPU /
 h:panelGroup
   h:selectOneMenu id=cpuids
value=#{HRselforeachcpuanduser.cpuid} 
   f:selectItems
value=#{HRselforeachcpuanduser.cpuids}/   
   /h:selectOneMenu
   h:message for=cpuids style=color:red/
/h:panelGroup


// this is backing bean code 

Corresponding java code
// this is for value change listener
   
public void hostSelection(ValueChangeEvent e) { 
  FacesContext context = FacesContext.getCurrentInstance(); 
  hostid=(String) e.getNewValue();
  getCpuids(); 
  context.renderResponse();
 }
//this is for  host select 

public Map getHosts(){
try{
  openConnection();
  selhostnames=new HashMap(); 
  String str=select distinct hostid from  system_cpu; 
  st=con.createStatement(); 
  rs=st.executeQuery(str);  
  
  while(rs.next()){
hostname=rs.getString(hostid);
System.out.println(hostname);
selhostnames.put(hostname,hostname);
  }
  return selhostnames;
}

public String getHost(){ 
return hostselected;
  }
  public void setHost(String hostselected){ 
this.hostselected = hostselected; 
  }

//this is for  cpu  selection
public Map getCpuids(){
   try{
 
 if(hostid==null){
 System.out.println(if it is null);  // imp  note
 return selcpunames;
 }
  openConnection();
  String str=select distinct cpuid from system_cpu where hostid=?;
  System.out.println(setting cpuids from host);
  ps=con.prepareStatement(str); 
  ps.setString(1,hostid);
  ps.execute();
  rs=ps.getResultSet(); 
  while(rs.next()){
cpuname=rs.getString(cpuid);
System.out.println(cpuname);
selcpunames.put(cpuname,cpuname);
  }
  return selcpunames;
   }   


public void setCpuid(String cpuid){
  this.cpuid=cpuid;
}
public String getCpuid(){
  
  return cpuid;
}



When I am running 
If its  null//in tomcat

And  

cpuids: Value is not a valid option.

What is the problem with my code please tell  and  what to change  

With regards
Shannu sarma
--
View this message in context:
http://www.nabble.com/selectonemenuitem-problems--Value-is-not-a-valid-optio
n-tf1917733.html#a5249864
Sent from the MyFaces - Users forum at Nabble.com.