• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Gather dataTable with selectOneMenu to bean

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, for couple days i struggle with that task.
I need to display datatable with names and choose from list another names to coapt.

Here is the snippet of code:


MyBean.performers returns list of performers with getName() method;
MyBean.userList returns list of users with getName() and getId() methods;

Whats the problem:
When i click "Save" i want to save the matches, e.g. Performer1: User2 (2), Performer2: User1(1), Performer3: User3(3).

I don't know how to get to these matchings from bean. I tried
HtmlDataTable htDT = (HtmlDataTable) FacesContext.getCurrentInstance().getUIViewRoot().findComponent("someDataTableId");
but it always returns null.

I did something with binding attribute but couldn't get that to work either.

Any sugestions?
Thanks in advance :-)
 
Bartender
Posts: 1845
10
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are displaying a list of performers in your data table.
Each "row" in that datatable should be related to one performer.
Each control in that datatable should be related to a field on that performer

I think your issue is that you have mapped the <f:selectOneMenu > control to your main backing bean #{MyBean.user} when it should be related to the object you are iterating with: #{perf.user} or similar.
The list of options in the menu (f:selectItems) can come from MyBean - thats the same list for all rows in the datatable presumably.

When you submit the page it should iterate through your list of performers, and set the value of "user" for each performer based on what you selected in each select one menu.

 
Matthew Constans
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stefan Evans wrote:
When you submit the page it should iterate through your list of performers, and set the value of "user" for each performer based on what you selected in each select one menu.



That's the thing i would like to achieve

I did like you said, moved the userList into performer but when i do saveIt the list of performers is null!

That is the part of bean i am talking about:



I did also control prints in setter methods of WFPerformers, none of them is called after i press "Save"
 
Matthew Constans
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Issue resolved, the problem was in import of sessionScope (faces.bean. / enterprise.context.). Me, dumb one, spent 7 hours of analysing code, when mistake wasn't there...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic