• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF Tables with checkboxes  RSS feed

 
Patrick Fong
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
     
    Bauke Scholtz
    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.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!