• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design pattern for setting request attributes?

 
Andy Hahn
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking for advice. To render my JSPs I am placing objects as request attributes and accessing them that way. Sometimes I need special methods that my pojos (most of which are hibernate) currently dont have. I would rather not add special formatting methods, etc to my pojos. Instead I would like to wrap the pojos with some type of view bean. Is there a recommended pattern for doing this?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like an approach down the wrong path. Why wrap the POJOs? Rather, custom tags and EL functions can keep display details separate from the data. Why try to mash them together?
 
Andy Hahn
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I try to avoid writing custom tags. I also hate maintaining them. But I see your point. Thanks
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about writing a class that has static methods that provide the special formatting?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom Reilly wrote:How about writing a class that has static methods that provide the special formatting?

The problem with that approach (unless the methods are mapped to EL functions) is that general methods cannot be called from the EL. And resorting to scriptlets just to avoid more modern methods isn't a valid approach.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic