The document discusses refactoring a Java EE 5 registration application to use the Seam framework. It begins with an overview of the original Java EE 5 application using JSF, managed beans and JPA. It then demonstrates refactoring the application to use Seam by replacing the managed bean with Seam components, removing faces-config.xml and adding Seam annotations and configuration. The refactoring simplifies the application and makes it more portable by reducing dependencies on XML configuration.
5. Java EE 5 Programming Model JSF Context DB Registration Application Managed Bean JSF Components Action Class Entity Class RegisterActionBean User ManagedBean
6. register.jsp: JSF In Action <td> Username </td> <td> < h:inputText id = "userName" value = " #{ user.username } " required = "true" > < f:validateLength minimum = "5" maximum = "15 " / > <td> Real Name </td> <td> < h:inputText id = "name" value = " #{ user.name } " required = "true" > <td> Password </td> <td> < h:inputSecret id = "password" value = " #{ user.password } " required = "true" > < f:validateLength minimum = "5" maximum = "15 " / > < h:commandButton id = "registerCommand" type = "submit" value = "Register" action = " #{ user.register } " / > A JSF Validator
7.
8.
9. Managed Bean public class ManagedBean { private String username ; private String name ; private String password ; public String getUsername() { return username; } Public String setUsernaame(String username) { this.username=username; } ... private RegisterActionLocal registerActionBean; private InitialContext ctx; { try { ctx = new InitialContext(); registerActionBean = (RegisterActionLocal) ctx.lookup("registration/RegisterActionBean/local"); } catch (NamingException ex) { ex.printStackTrace(); } } public String register () { return registerActionBean.register(username, name, password); }
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20. Seam Registration Application JSF Context DB Action Class Entity Class Seam Framework JSF Components RegisterActionBean User