Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JSF Tables with checkboxes

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I was wondering if someone could give me some pointers on constructing and processing checkboxes in a database table. I'm using JSF 1.2 and Tomahawk. Here is my JavaBean -


Here is my backing bean



What I need to do is list down all possible PLANNING, DOING and DONE activities. Then I want to select the checkboxes of the assigned activities of the fore-mentioned types. Then I want to be able to process the assigned and un-assigned activities.

This is where I'm not sure as I'm a JSF newbie. This is my attempt at writing the JSF page. Needless to say, it doesn't quite work the way it should. (This is only for PLANNING activities). Should there be a binding




My questions are
  • How do you write the JSF page to list activities of each type with checkboxes? How do I include assigned activities?
  • How do you process the check boxes or reference the checkboxes that are checked?
  • What should be in the constructor for AssociatedAttributeBean?


  • Cheers
    Patrick
     
    Ranch Hand
    Posts: 2458
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Inside an UIData component you should bind every component value to a property of the iterated row object, not to the parent backing bean. Otherwise the property of the parent backing bean will simply be overwritten everytime from up to the value of the last row. In this case you need to move the 'possiblePlanningActivities' property to the 'Activity' class and bind the value of the checkbox with #{currentRow.possiblePlanningActivities} instead.

    Another alternative is to bind it to a Map<TypeOfUniqueRowIdentifier, Boolean> property of the backing bean, where in TypeOfUniqueRowIdentifier should hold the value which represents the unique ID of the object behind "currentRow", the 'Activity' class. In this case I assume that the 'name' property is unique, so make 'possiblePlanningActivities' a Map<String, Boolean> property in the backing bean and bind the value of the checkbox with #{AssociatedAttributeBean.possiblePlanningActivities[currentRow.name]}. On checked rows, the Boolean property will evaluate to true.
     
    I once met a man from Nantucket. He had a tiny ad
    Thread Boost feature
    https://coderanch.com/t/674455/Thread-Boost-feature
      Bookmark Topic Watch Topic
    • New Topic