Hi, not sure, but you have String values in selectItems and int value in probability.
try Private String probability; public String getProbility() { Return probability; } public void setProbility(String probility) { this.Probility = probility; } or SelectItem[] selectItemArry = new SelectItem[4]; selectItemArry[0] = new SelectItem(new Integer(0), ""); selectItemArry[1] = new SelectItem( new Integer(5), "5:High" ); selectItemArry[2] = new SelectItem(new Integer(3), "3:Medium" ); selectItemArry[3] = new SelectItem(new Integer(1), "1:Low" ); regards, Volker 2007/1/18, Wong, Emmanuel (Sam) <[EMAIL PROTECTED]>:
Yes, but the drop down box should display "3:Medium" if I set the probability = 3; I was not able to display "3:Medium" when I set probability = 3; thannks -----Original Message----- From: Volker Weber [mailto:[EMAIL PROTECTED] Sent: Thursday, January 18, 2007 4:18 PM To: MyFaces Discussion Subject: Re: [tobago] f:selectItem with tc:selectOneChoice You want '3' as inital value? just set it: Public class MyBean{ private int probability = 3; ... } reagards, Volker 2007/1/18, Wong, Emmanuel (Sam) <[EMAIL PROTECTED]>: > > > > > > > > Hi: > > Could anyone tell me how to display a specified drop down list > value? Let say will would like to display "3:Medium" instead of other drop > down value. Please see below. Thanks. > > > > > > For example: > > On the JSP: > > < tc:selectOneChoice > > value= "#{ > MyClassController.myBean.probability}" > > required= "false"> > > <f:selectItems value="#{ MyClassController.probability}" > /> > > </ tc:selectOneChoice > > > > > On the Backing Bean: > > > > public class MyClassController{ > > > > private MyBean myBean; > > public SelectItem[] _probability; > > > > public SelectItem[] getProbability() { > > > > SelectItem[] selectItemArry = new SelectItem[4]; > > selectItemArry[0] = new SelectItem("0" , ""); > > selectItemArry[1] = new SelectItem( "5", "5:High" ); > > selectItemArry[2] = new SelectItem( "3", "3:Medium" ); > > selectItemArry[3] = new SelectItem( "1", "1:Low" ); > > > > } > > } > > > > Public class MyBean{ > > > > Private int probability; > > > > public int getProbility() > > { > > Return probability; > > } > > > > Public void setProbility(int probility) > > { > > This.Probility = probility; > > } > > } > > > > > -- > Dennis Byrne