Notes
Slide Show
Outline
1
 
2
Training @ JavaSchool.com
3
Struts Frameworks
  • Extends Servlet-Controller in a function-specific Action


  • Uses struts-config.xml file to define all function-actions


  • Collects the data from the web forms into specific ActionForm classes that keep data state between requests


  • Maps each Action to its ActionForm in the struts-config.xml


  • Introduces a powerful set of tag libraries


  • And more…
4
Struts Frameworks for Web Application
5
Application Parameters
in the web.xml
6
Application Parameters
in the web.xml
7
Application Parameters
in the web.xml
8
Application Parameters
in the web.xml
9
Struts Tag Library
10
Define Your Plan of Actions
in the struts-config.xml
11
Define Your Plan of Actions
in the struts-config.xml
12
Define Your Plan of Actions
in the struts-config.xml
13
Start Writing a Struts Action
14
We are going to write JSP
What do you remember about JSP?
15
Write the Topic.jsp page
16
Continue the Topic.jsp page with more Struts Tags and Internationalization
17
Displaytag Custom Library
18
Example from the Login.jsp Page
19
Struts Summary
  • Extends Servlet-Controller ….


  • Uses struts-config.xml file to ….


  • Collects the data from the web forms into …


  • Maps each Action to its … in the …


  • Introduces a powerful set of …



20
Struts Summary
  • Extends Servlet-Controller in a function-specific Action


  • Uses struts-config.xml file to define all function-actions


  • Collects the data from the web forms into specific ActionForm classes that keep data state between requests


  • Maps each Action to its ActionForm in the struts-config.xml


  • Introduces a powerful set of tag libraries


  • And more…
21
Displaytag Custom Library
Makes Easy Creating Tables
With Sorted Columns
22
Here is the Login.jsp Page
23
Data Access from Web Application
24
Struts – Spring - Hibernate
25
Hibernate
  • Uses OO query language called HQL


  • Uses objects instead of tables and fields instead of columns


  • Provides object-to-relational mapping for most DBs


  • Separates data layer from business logics


  • Uses DB connection info to retrieve DB schema


  • Generates DAO beans with data fields mapping table columns


  • Generates Insert/Update/Delete/Select statements for DB tables
26
Hibernate Synchronizer
27
Spring’s Map to Hibernate
28
Spring Maps Data Source Dialect
and Provides Transaction Management for Hibernate Operations
29
Spring and Hibernate
Reduce Business Code
30
Example of DAO Class Generated by Hibernate
31
Struts – DataService
32
Data Intensive Web Application
33
Design and Code Hints: Getting Data
34
Design and Code Hints
 Use common data services, avoid code duplications, and focus more on a business side of applications.
35
OMD
36
Sequence Diagram
37
 Specific Action Implementation Example
38
LoginBean Class Example
39
SQL Statements
40
Data Status Diagnostics
41
Self-Test Facilities
Web Application Unit Test
42
Automated System Test Scenario
43
DataService API
  • Include the library “com.its.util.jar” in the CLASSPATH and import com.its.util.DataService


  • // execute insert/delete/update SQL statements stored in the “sqlLocation”
  • @ param sqlStatementName for example “getLogin” stored as the “getLogin.sql”
  • @ param map of key-values to replace SQL <<keys>> with run-time values
  • @ return numberOfRowsEffected
  • public static int setData(String sqlStatementName, HashMap map)
  • // use other than “DataSource” connection pool
  • public static int setData(String sqlStatementName, HashMap map, String dsName)


  • // execute select statement and return a list of record-beans
  • @ param sqlStatementName for example “getLogin” stored as the “getLogin.sql”
  • @ param map of key-values to replace SQL <<keys>> with run-time values
  • @ param beanClass (e.g. LoginBean.class) supports records retrieved by the SQL statement
  • @ return list of objects of the beanClass
  • public static List getData(String sqlStatementName, HashMap map, Class beanClass)
  • // use other than “DataSource” connection pool
  • public static List getData(String sqlName, HashMap map, Class beanClass, String dsName)


  • @param dataSource your DataSource specified in JNDI context
  • @param dataSourceName of your DataSource specified as JNDI name
  • public static void setDataSource(DataSource dataSource, String dsName)
  • public static void setDataSource(DataSource dataSource)
44
More DataService API
45
Use DataService Frameworks to Define Custom Actions
in the struts-config.xml
46
Diagnostics and Custom Actions
47
Exception handling with DataService
48
Use DataService Diagnostics Facilities
49
Web Application Frameworks
Summary/Repetition
  • 1. Struts


  • 2


  • 3


  • 4
50
Web Application Frameworks
Summary/Repetition
  • 1. Struts


  • 2 Spring


  • 3 Hibernate


  • 4 DataService