This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Linking selectItem in loop with list not from backing bean

 
Vlad Kolosnicin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i need some help with displaying several selectOneMenu's from DB. Each one has it's own options, stored in DB too.

so i iterate answers List with dataTable. on each iteration currAnswer is an Entity that has List of answeredOption. This list i try to iterate in c:forEach to manually inser f:selectItem.
scnbjectConverter is a custom converter to convert entity class to String such as "org.survey.model.VoteOption,1" (class name and Id), but it doesn't matter, model and service tier are correct and problem appeared in presentation tier



when i try to link it directly to entity list (annotated as @OneToMany) my selectOneMenu is empty (that list is fully initialized and isn't empty)

but everything works fine if i link c:forEach to List field, that i manually initialize with the same (!) answeredOption list in some backing bean:


i have very complex structure, so this solution with backing bean field isn't appropriate.

i've tried ui:repeat insted of forEach, but it didn't help too.
[ July 11, 2008: Message edited by: Vlad Kolosnicin ]
 
Zack Marrapese
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't you use an f:selectItems tag and just get your list of entities in the backing bean and then create SelectItem objects from them? Using JSF components within c:forEach doesn't normally work very well.
Something to do with the order of tag rendering and the mismatch between JSP and JSF lifecycles. c:forEach doesn't normally work with facelets either.
 
Vlad Kolosnicin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2 Zack Marrapese
thanks for my mind direction. For personal usability i've added new transient field into my entity to get ready-to-use list of SelectedItem:



on the page simply :


it isn't pure MVC, but has less code. and works fine)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic