Dilemma: Templates vs. Presentation beans.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   valentin_tihomirov
Posted On:   Saturday, July 5, 2003 05:22 AM

I need to create a view for editing a record in a database. Once record is edited by user the database should be modifyed (the record is inserted or updated). That is the view is almost looks the same for the both types of modification. The only differences are header, hidden dipatch field and primary key for the record (it cannot be modifyed in update scenario). I see 3 solutions: use logic tag in throughout the JSP rendering different content; use dubclassing of tiles, that is the base modify.jsp tile in extended by two add.jsp and update.jsp tiles. Whereby, the deriviatives specify appropriate messages, ui cotrols for user; Use two presentation beans (PB). The action would choose one of them putting the bean with   More>>

I need to create a view for editing a record in a database. Once record is edited by user the database should be modifyed (the record is inserted or updated). That is the view is almost looks the same for the both types of modification. The only differences are header, hidden dipatch field and primary key for the record (it cannot be modifyed in update scenario).
I see 3 solutions:


  1. use logic tag in throughout the JSP rendering different content;

  2. use dubclassing of tiles, that is the base modify.jsp tile in extended by two add.jsp and update.jsp tiles. Whereby, the deriviatives specify appropriate messages, ui cotrols for user;

  3. Use two presentation beans (PB). The action would choose one of them putting the bean with appropriate ui mesages into request context, where JSP can find the bean and use it for rendering.



IMO, the first is quite cumbersome (non-OOP) approach. The second is complicated for me. The last one is redundant as it can lead to inconsistent situations where more than two PBs are created; whereby, some of them have fields not related to MODIFY and ADD views. In addition, I feel that there is a problem of localisation using this approach with PBs. Can I store a key of my message into the request context for a JSP tag?


What are your considerations choosing the best one?

   <<Less
About | Sitemap | Contact