Antipatterns and Pitfalls

N/ACitations
Citations of this article
2Readers
Mendeley users who have this article in their library.
Get full text

Abstract

This chapter covers antipatterns and pitfalls of day-today JSF development. Many of these issues have kept us up at night, and most of these are old problems with new faces: performance , tight coupling, cache management, thread safety, security, and interoperability. N Plus One The N Plus One antipattern typically finds its way into web applications in a scenario like this: You want to render a web page of purchase orders along with some data about the customer of each order. This data must be read from a database. An efficient approach would be to pull a single dataset by joining the Customer table and the Order table. A far less efficient approach would be to read a dataset from the Order table, iterate over this dataset, and go back to the database for detailed customer information related to that order. The first approach costs one round-trip; the second approach costs N plus one round-trips, where N is the number of orders. Let's look at how this antipattern can find its way into JSF applications. The powerful Open Transaction in View pattern has grown popular among application developers using object-relational mapping (ORM) frameworks. In the Hibernate community, the pattern often goes by a slightly different name, Open Session in View. This pattern begins by opening a transaction in a servlet filter as the request arrives and closing the transaction before the response is sent. The OpenTransactionInViewFilter class (OTVF) is an implementation of this pattern: public class OpenTransactionInViewFilter implements Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) { try { ObjectRelationalUtility.startTransaction(); chain.doFilter(request, response); // commits transaction, if open ObjectRelationalUtility.commitTransaction(); } catch (Throwable throwable) {

Cite

CITATION STYLE

APA

Antipatterns and Pitfalls. (2008). In The Definitive Guide to Apache MyFaces and Facelets (pp. 229–269). Apress. https://doi.org/10.1007/978-1-4302-0344-5_7

Register to see more suggestions

Mendeley helps you to discover research relevant for your work.

Already have an account?

Save time finding and organizing research with Mendeley

Sign up for free