• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Submitting Input Fields In a Datatable

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

I'm trying to solve a problem which I would seem to think is quite intuitive to solve but just can't seem to get it going. Any suggestions you can offer would be greatly appreciated.

Basically, I have a managed bean in the request scope which contains a List<String>.

I create a datatable (actually its a RichFaces datatable) which iterates through the List above and creates an input text field for every entry. My problem is when I submit the form, the List in the managed bean is not updated and remains empty. I'm completely at a loss as to how to make this work. I've even tried binding the table to a back bean and iterating through the children of the HtmlDataTable object with no success. To make sure I am understanding things properly, I even added a simple input text field outside the datatable to make sure it was properly submitted.

Here is my page code:



Here is my managed-bean:

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

First a comment, id is unique. So two times id="id_cosName" is not a good idea.

You can try to put the managed bean in session scope. Maybe that will work.

Bertjan


 
Eric Richer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Bertjan,

The duplicate ID is just a spelling error. Putting the managed bean in session scope definately makes things easier. In the request scope though it is possible to make it work. I ended up getting the behaviour I want by accessing the parameter map in the HttpServletRequest and then manually populating the List. I'm guessing there isn't inherent support in the datatable for restoring a property of type List as the property's setter method is never even invoked.

Thanks for the input.

Cheers
 
God is a comedian playing for an audience that is afraid to laugh - Voltair. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic