• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trouble using Map with h:selectOneMenu...  RSS feed

 
Vinnie Jenks
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the book "Core JavaServer Faces" and in there it says that I can use a plain Map collection with selectItems in a selectOneMenu.

I'm able to get it to work on one app but not another...using the same JSF implementation on the same app server...so naturally I'm completely confused...to say the least.

I'm using Sun's Glassfish V1 and the official JSF 1.2 reference implementation it comes with. I'm not interested in MyFaces or another alternative...I want to stick w/ the built-in faces impl.

Anyhow, I have an enterprise app that has a page w/ this in it:



In the backing-bean, the list is populated like so:



In another app I've done it *exactly* the same way...



...but I get an exception!!



What am I doing wrong? I'm completely stumped. Can I use a Map or not? If no, why did it work once and not twice in *identical* situations!?

Thanks!
 
Eugene Abarquez
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I believe you can populate <h:selectOneMenu> using Map. From the error, it looks like there's a syntax error in your jsp page somewhere.
 
Ankur Thakur
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Theist what ever you want to get or to add that must be belong to Select item class or that type always return List
See this code here


public void setSelectSection(String selectSection) {
this.selectSection = selectSection;
}

public List<SelectItem> getSelectSelectioncatagorey() {
selectSelectioncatagorey = new ArrayList<SelectItem>();
selectSelectioncatagorey.add(new SelectItem("", "Select Catagorey"));
selectSelectioncatagorey.add(new SelectItem("PIN", "PIN"));
selectSelectioncatagorey.add(new SelectItem("PRN", "PRN"));
return selectSelectioncatagorey;
}
 
Ankur Thakur
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what ever you want to get or to add that must be belong to Select item class or that type always return List
See this code here


public void setSelectSection(String selectSection) {
this.selectSection = selectSection;
}

public List<SelectItem> getSelectSelectioncatagorey() {
selectSelectioncatagorey = new ArrayList<SelectItem>();
selectSelectioncatagorey.add(new SelectItem("", "Select Catagorey"));
selectSelectioncatagorey.add(new SelectItem("PIN", "PIN"));
selectSelectioncatagorey.add(new SelectItem("PRN", "PRN"));
return selectSelectioncatagorey;
}
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!