You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by sarma <ss...@mahindrabt.com> on 2006/07/15 14:56:39 UTC
Value is not a valid option
Hi,
i am using two selectonemenus in my application
one selectone is for host (system)
second selectone is for cpu (cpus of the system)
if i select first host (any hostname)the value change listeners fires and
it gives
the corresponding cpus of the host from the database and sets to second
selectonemenu .
but when i submitted to a next form
i am getting a error
Value is not a valid option
This is jsp code.
<h:outputText value="SelectHOST "/></th>
<h:panelGroup>
<h:selectOneMenu id="hostids" value="#{HRselforeachcpuanduser.users}"
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>
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
if any one has guts to solve this problem please solve
with regards
shannu sarma
--
View this message in context: http://www.nabble.com/Value-is-not-a-valid-option-tf1947496.html#a5340222
Sent from the MyFaces - Users forum at Nabble.com.