If you have been looking for a good overview of Design Patterns in J2EE, look no further. In this article you will learn about Design Patterns and how they interact with J2EE's tier-based development. It covers three of the most common Design Patterns, and provides a real-world example of Design Patterns in action.
J2EE Design Patterns: Getting Started - View component and DTO (Page 4 of 4 )
The View component calls the controller component which in turn uses the DAO implementation to get the connection. Then it creates a DTO and passes it to the next View Component if the username and password are correct.
package loginmodule.dto; public class LoginDTO { String user; String favColor;
public LoginDTO() { } //the constructor called by service class to populate the dto public LoginDTO(String user, String favColor) { this.user=user; this.favColor=favColor; } public void setUser(String user) { this.user = user; } public String getUser() { return user; } public void setFavColor(String favColor) { this.favColor = favColor; } public String getFavColor() { return favColor; } }
That’s it. In this part I have given a glimpse of what Design Patterns are and what can be achieved by implementing design patterns in context of J2EE. From the next part onwards I will focus on each Design Pattern available for each of the tiers. Till then…
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.