• 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

JSF - Rich Faces - Suggest Design for Checkboxes column in Data table

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

I have following design issue with JSF rich faces.

I have a rich table which will display rows of a table through a Entity class.
-->Now I need to add a checkbox column to it <--

So is it a good programming practise to place a field in my entity class, like following ?

@Entity
class Person
{
...
...
...
@transient
boolean selected = false;
}


Are we overloading Entity? what about the scenarios where in we do not require those additional transient fields?
Can I have wrapper around Person entity saying

class PersonWithUIState extends Person
{

private boolean selected = false;
private boolean editable = false;
private boolean deletable = false;

etc...

}


Please suggest.

}
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you can extend the domain model class (Person) with decorations on it to make a UI model class and use instances of that class as the wrapped row data for a dataTable. Or you can use one of the other common design patterns that allow similar enhancements. A lot of people think that the UI data model MUST be the domain model, and it simply isn't so.

As a general rule, I wouldn't modify the domain model class itself. It's too much like mixing business logic in with your persistence data definitions. And in many shops, the domain model may be a jar (or EJB jar) that comes from some other group and isn't easy to get modified. Especially if just one application needs it.
 
Srinivasan thoyyeti
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim. By the way could you please point any one pattern which is already addressing this problem?
 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Decorator pattern is probably the closest, although without checking the fine details I often have trouble distinguishing one enhancement pattern from another.
 
reply
    Bookmark Topic Watch Topic
  • New Topic