This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Design pattern for setting request attributes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Design pattern for setting request attributes?" Watch "Design pattern for setting request attributes?" New topic
Author

Design pattern for setting request attributes?

Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225
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

Joined: Jan 10, 2002
Posts: 60785
    
  65

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225
I try to avoid writing custom tags. I also hate maintaining them. But I see your point. Thanks
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
How about writing a class that has static methods that provide the special formatting?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Design pattern for setting request attributes?
 
Similar Threads
SkillSet of Web Work
Showing attributes and methods in Class Diagram
POJO class + Singleton
Value objects
Validity of Session Facade in JavaEE