Struts Advanced
Custom JSP Tag Libraries
Objectives
- JSP taglib Directive
- Components of a Tag library
- The JSP File
- The Tag Library Descriptor
- The Tag Handler Class
- An Example
- The TLD File – carPrice.tld
- TLD File – Example
- The Handler Class – CarPriceHandler.java
- The Handler Class – Example
- The JSP File – Carprice.jsp
- Tag Lib Handler Lifecycle
- Directory Structure: where Custom Tag Libraries Fit
- Struts TagLib
- Bean Tags
- <bean:define>
- <bean:message>
- <bean:page>
- <bean:include>
- <bean:cookie>
- <bean:resource>
- <bean:write>
- <bean:header>
- <bean:parameter>
- HTML Tags
- <html:form>
- <html:submit>
- <html:text>
- <html:link>
- <html:password>
- <html:errors>
- <html:message>
- <html:message>
- <html:multibox>
- <html:select>
- <html:options>
- Logic Tags
- Logic Tags functionality
- <logic:equal>
- <logic:greaterEqual>/<logic:lessEqual>
- <logic:lessThan>/<logic:notEqual>
- <logic:notEmpty>
- <logic:iterate>
- Template Tags
- Example of Template Tags
- Summary
Struts Extensions, Internationalization and Error Handling
- Objectives
- Struts Extensions
- Extension Points
- Plug-ins
- A plug-in example
- Custom Configuration Class
- Writing a Configuration Class
- Custom Struts Servlet
- Custom Request Processor
- Base Action Class
- Base Form Beans
- Custom JSP Tags
- Disadvantages of Using Extensions
- Internationalization (I18N)
- Error Handling
- The ActionError class
- Error Handling : validate() method of ActionForm
- Displaying the errors found in the validate method
- Error Handling : execute() method of Action
- Declarative Exception Handling
- Syntax of declarative exception handling
- Programmatic Exception Handling
- Logging from Struts
- Using Commons Logging and Log4J in Struts
- Writing Commons Logging Code
Miscellaneous Advanced Features
- Advanced Features Discussed in This Chapter
- Integration of Jakarta Common Libraries - BeanUtils
- Integration of Jakarta Common Libraries - Digester
- Multiple Application Support
- DynaActionForms
- Validators
- Adding the Validator framework to a Struts application
- A tale of three files
- A sample rule in the file validator-rules.xml
- A rule in validator-rules.xml (continued)
- validator.xml file
- Validator Dependency
- Rule Variables
- Error Message
- Basic Validation Rules
- Client Side Validation
- Validating multiplication example using DynaActionForm
- Writing Custom Validators
- Validator Class Example
- HTTP Redirection
- Working With Check Boxes
- Context Sensitive Form Validation
Database Programming
- Basic Concepts
- MVC Interaction
- Database Connection
- Transaction Management
- Data Source
- Defining a Struts Data Source
- Opening a Connection from a Struts Data Source
- Creating an Editor Form
- Example Form Display Action
Templates and Tiles
- Objectives
- Struts Templates
- Defining the Template
- A template
- Using the template in a JSP
- <template:insert>
- <template:put>
- A JSP that uses the template
- Struts Templates
- Templates as UI components
- Struts 1.1 Tiles Support
- Tiles
- Tiles example
- A JSP that uses the layout
- Tiles go beyond templates
- Inheritance in tiles definitions
- Definitions as Struts “forwards”
- Template or Tiles?
Unit Testing Struts Applications
- Objectives
- Unit Testing Struts Applications
- What is JUnit?
- Why JUnit?
- A JUnit Test
- Running the tests
- JUnit Basics
- A simple Struts test case
- The testcase
- Downloading STC
- Running STC inside WSAD
- Running STC inside WSAD …
- Executing the test
- Testing Strategies
JSTL
- JSP Expression Language (EL)
- Basic Usage
- Built-in Objects
- Working With Arrays and Maps
- Operators
- Full Example
- The future of Struts Tags
- JSP Standard Template Library (JSTL)
- Run Time Version
- Basic Tags
- Condition Tags
- Interator Tags
- Internationalization (I18N)
- Setting Preferred Locale
- Specifying Resource Bundle
- Display Translated Text
- Display Number
- Display Date
- JDBC Tags
- Specify Data Source
- Performing a Query
- Display Result
- Pagination Example
- XML Tags
Common Solutions
- File Upload in Struts
- <html:file/>
- A Sample Jsp with html:file tag
- ActionForm Class
- Action class to Store the File
- Action class ..contin
- Preventing Duplicate Form Submission
- Struts Mechanism to Manage Duplicate Form Submission
- Action class – Loadjsp.java
- dataEntry.jsp
- Source of dataEntry.jsp
- Action class –DuplicateCheck.java
- Dealing with Check boxes
- Html File with Checkbox tag
- XML transform using XSLT
- Formatting XML Documents
- XSL
- Three Parts of XSL
- XSLT – XSL Transformation
- <xsl:stylesheet>
- <?xml-stylesheet>
- <xsl:template>
- <xsl:value-of>
- Navigating with XPath
- <xsl:for-each>
- Javax.xml.transform Package
- Transformer
- Simple.xml
- Simple.xsl
- Servlet
- Summary
JavaServer Faces (JSF)
- Introduction to JSF
- Why JSF
- JSF Request Processing
- JSF request/response Lifecycle
- Why Integrate JSF and Struts
- Struts-Faces Integration Tag Library
- Techniques on Integrating JSF with Struts
- Create a Dynamic Web Project
- Add the Struts-faces Jar
- web.xml
- struts-config.xml
- Sample JSP File Using the Struts-faces tags
- Summary