• Post Reply Bookmark Topic Watch Topic
  • New Topic

SelectItem  RSS feed

Vibhas Kumar
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends I have one doubts in SelectItem constructor having two parameters the constructor is defined like this in java api public SelectItem(java.lang.Object value, java.lang.String label) in which the 1st parameter takes an Object type and the 2nd one as string. Now the problem is when i pass the value as an object i.e the 1st parameter i m not able to see the labels when it renders in webpage but when i convert that object to string by using toString() method it renders the value in webpage.

It is something like this

jsp page

<hutputText value="Select choices given below :"/><br><br>
<h:selectManyListbox id="subscriptions" value="#{SItemsBean.options}" size="3">
<f:selectItems value="#{SItemsBean.options}" />

public class SItemsBean
private List options;
public SItemsBean()

SomeClass smc = new SomeClass();
options = new ArrayList();
SelectItem option = new SelectItem(smc, "choice2);// this is just an overview what i m trying to say
// now if i keep the 1st parameter of SeletItem as it is it wont show me the label as choice2 in my webpage but if
// i make the 1st parameter as smc.toString() then it shows me the lablel as choice2 in webpage but why it is so?
// the 1st parameter is an object itself why it needs to be a string only the 1st parameter is what we want to send

// on selecting the label in webpage it is not giving any syntax error because it is perfectly fine but not displaying
// the data i have also tried with the getter of selected label as of Type SomeClass but not working please help

public void setOptions(List opt) {
options = opt;

public List getOptions()
return options;


  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!