21
Developing a Developing a Struts & Tiles Struts & Tiles application using application using WebSphere Studio WebSphere Studio Dan Velasco Dan Velasco

Developing a Struts & Tiles application using WebSphere Studio

  • View
    3.129

  • Download
    0

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Developing a Struts & Tiles application using WebSphere Studio

Developing aDeveloping a Struts & Tiles application Struts & Tiles application using WebSphere Studiousing WebSphere Studio

Dan VelascoDan Velasco

Page 2: Developing a Struts & Tiles application using WebSphere Studio

IntroductionIntroduction Going to cover Struts & TilesGoing to cover Struts & Tiles Why not JavaServer Faces - yetWhy not JavaServer Faces - yet Model-View-Controller architectureModel-View-Controller architecture Will show a Struts & Tiles enabled Will show a Struts & Tiles enabled

sample directory search applicationsample directory search application Will intersperse talk with WebSphere Will intersperse talk with WebSphere

Studio Application Developer (WSAD) tipsStudio Application Developer (WSAD) tips Questions and comments welcome Questions and comments welcome

during the presentationduring the presentation

Page 3: Developing a Struts & Tiles application using WebSphere Studio

About MeAbout Me IBM Certified Solution Developer – IBM Certified Solution Developer –

WebSphere Studio V5WebSphere Studio V5 Sun Certified Java Programmer Sun Certified Java Programmer Sun Certified Web Component DeveloperSun Certified Web Component Developer Been doing Web development for six Been doing Web development for six

yearsyears Started off development career with Started off development career with

pure HTML, then did Notes & Domino, pure HTML, then did Notes & Domino, and have transitioned to Java, J2EE and and have transitioned to Java, J2EE and WebSphereWebSphere

Page 4: Developing a Struts & Tiles application using WebSphere Studio

More about meMore about me Senior Technical Editor and tip writer Senior Technical Editor and tip writer

for WebSpherePower & DominoPower for WebSpherePower & DominoPower MagazinesMagazines

Senior Web Developer for Sutter Senior Web Developer for Sutter ConnectConnect

Reach me at Reach me at http://DanVelasco.comhttp://DanVelasco.com or [email protected] [email protected]

Page 5: Developing a Struts & Tiles application using WebSphere Studio

Introduction TopicsIntroduction Topics Show how to create a Struts-enabled Show how to create a Struts-enabled

application using WebSphere Studio application using WebSphere Studio Application DeveloperApplication Developer

Show what files (JARs, tlds, etc.) are requiredShow what files (JARs, tlds, etc.) are required Review configuration of the web.xml and Review configuration of the web.xml and

struts-config-xml filesstruts-config-xml files Show sample directory application in actionShow sample directory application in action Explain actions in directory applicationExplain actions in directory application Quick introduction to how Tiles worksQuick introduction to how Tiles works

Page 6: Developing a Struts & Tiles application using WebSphere Studio

Advanced TopicsAdvanced Topics InternationalizationInternationalization

Resource BundlesResource Bundles Changing the complete look & feel of an Changing the complete look & feel of an

application in minutes using Tilesapplication in minutes using Tiles Advanced features of the directory Advanced features of the directory

searchsearch Struts enables you to focus on functionalityStruts enables you to focus on functionality Links to multiple result pagesLinks to multiple result pages Class to build SQL queriesClass to build SQL queries

Lessons learnedLessons learned

Page 7: Developing a Struts & Tiles application using WebSphere Studio

Struts diagramStruts diagram

Page 8: Developing a Struts & Tiles application using WebSphere Studio

Creating a Struts-enabled Creating a Struts-enabled applicationapplication

Demo using WebSphere Studio Demo using WebSphere Studio Application DeveloperApplication Developer Update WebSphere Studio to get the Update WebSphere Studio to get the

latest version of Strutslatest version of Struts If you use another IDE, you might If you use another IDE, you might

have a similar wizardhave a similar wizard You’ll see what files are requiredYou’ll see what files are required On to the demo!On to the demo!

Page 9: Developing a Struts & Tiles application using WebSphere Studio

DemoDemo Creating Struts-enabled application Creating Struts-enabled application

using WebSphere Studio Application using WebSphere Studio Application DeveloperDeveloper

Page 10: Developing a Struts & Tiles application using WebSphere Studio

The web.xml fileThe web.xml file Fairly simple, you do need to Fairly simple, you do need to

configure the Action (Controller) configure the Action (Controller) servletservlet

Configure the Struts custom tag Configure the Struts custom tag librarieslibraries

Page 11: Developing a Struts & Tiles application using WebSphere Studio

The struts-config.xml fileThe struts-config.xml file Configure all of your Actions, which Configure all of your Actions, which

extend the Struts Action classextend the Struts Action class Configure one or more data source Configure one or more data source

definitionsdefinitions Configure your message resource Configure your message resource

bundlebundle Configure your tile definitions/pathsConfigure your tile definitions/paths

Page 12: Developing a Struts & Tiles application using WebSphere Studio

DemoDemo The person directory sample The person directory sample

applicationapplication Based on a real project, but abstracted Based on a real project, but abstracted

to make it more generalto make it more general Code available to download at Code available to download at

http://DanVelasco.com/exampleshttp://DanVelasco.com/examples Tiles demo/overviewTiles demo/overview

Page 13: Developing a Struts & Tiles application using WebSphere Studio

Advanced TopicsAdvanced Topics InternationalizationInternationalization Changing the complete look & feel of an Changing the complete look & feel of an

application in minutesapplication in minutes Advanced features of the directory Advanced features of the directory

searchsearch Struts enables you to focus on functionalityStruts enables you to focus on functionality Links to multiple result pagesLinks to multiple result pages Class to build SQL queriesClass to build SQL queries

Lessons learnedLessons learned

Page 14: Developing a Struts & Tiles application using WebSphere Studio

InternationalizationInternationalization Three requirementsThree requirements

1)1) Create and use Create and use ApplicationResource.properties file for ApplicationResource.properties file for languages you want to supportlanguages you want to support

• Default (English): ApplicationResources.propertiesDefault (English): ApplicationResources.properties• Spanish: ApplicationResources_es.propertiesSpanish: ApplicationResources_es.properties

2)2) Use <html:html locale=“true”> tag on Use <html:html locale=“true”> tag on your JSP pagesyour JSP pages

3)3) Switch your browser language and Switch your browser language and close and restart your browserclose and restart your browser

Page 15: Developing a Struts & Tiles application using WebSphere Studio

Changing the look and feel of a site Changing the look and feel of a site in minutesin minutes

You can change the look and feel of a You can change the look and feel of a site in minutes by doing the followingsite in minutes by doing the following Create an alternate tile definition file or Create an alternate tile definition file or

modify your existing tile definition filemodify your existing tile definition file Create another layout manager file to Create another layout manager file to

customize the Tiles layoutcustomize the Tiles layout Use CSS for all formatting and then use Use CSS for all formatting and then use

different CSS files in the layout manager different CSS files in the layout manager filefile

Change your tile definition file and then Change your tile definition file and then restart the containerrestart the container

Page 16: Developing a Struts & Tiles application using WebSphere Studio

Advanced Features of the Directory Advanced Features of the Directory SearchSearch

Links to multiple result pagesLinks to multiple result pages Similar to what you get on most Similar to what you get on most

websiteswebsites Needed to save the search form fields Needed to save the search form fields

into the sessioninto the session Configured using the /PersonSearchMore Configured using the /PersonSearchMore

action mapping, which reuses the action mapping, which reuses the PersonSearchAction classPersonSearchAction class

Next and previous buttonsNext and previous buttons

Page 17: Developing a Struts & Tiles application using WebSphere Studio

Advanced Features of the Directory Advanced Features of the Directory Search (cont.)Search (cont.)

Class to build SQL QueriesClass to build SQL Queries Queries can get complicated, so needed a static Queries can get complicated, so needed a static

class method to build the codeclass method to build the code Enables you to build a plain English version of Enables you to build a plain English version of

the query which you can present to the user the query which you can present to the user log4Jlog4J

Helps immensely with troubleshootingHelps immensely with troubleshooting Can be turned on or off from a configuration fileCan be turned on or off from a configuration file Can log to the console, a text file or even a Can log to the console, a text file or even a

databasedatabase

Page 18: Developing a Struts & Tiles application using WebSphere Studio

Lessons LearnedLessons Learned Learning Struts before completely learning Learning Struts before completely learning

JSPs, Servlets, custom tag librariesJSPs, Servlets, custom tag libraries Separating learning Java/J2EE and learning Separating learning Java/J2EE and learning

WebSphereWebSphere Use the power of your IDE Use the power of your IDE The tileDefinitions versus tilesDefinitions The tileDefinitions versus tilesDefinitions

problemproblem Use the power of the custom tag librariesUse the power of the custom tag libraries Use the flexibility of the application Use the flexibility of the application

resource bundlesresource bundles

Page 19: Developing a Struts & Tiles application using WebSphere Studio

For more informationFor more information IBM developerWorksIBM developerWorks

http://www.ibm.com/developerworks/http://www.ibm.com/developerworks/ Article: Writing a Simple Struts ApplicationArticle: Writing a Simple Struts Application

http://www.ibm.com/developerworks/websphere/techjournal/0302_fung/fung.html http://www.ibm.com/developerworks/websphere/techjournal/0302_fung/fung.html Article: Integrating Struts, Tiles, JavaServer FacesArticle: Integrating Struts, Tiles, JavaServer Faces

http://www.ibm.com/developerworks/library/j-integrate/http://www.ibm.com/developerworks/library/j-integrate/ WebSpherePower (http://WebSpherePower.com)WebSpherePower (http://WebSpherePower.com) WebSphere Advisor (http://Advisor.com)WebSphere Advisor (http://Advisor.com) WebSphere Journal (http://sys-con.com/websphere/)WebSphere Journal (http://sys-con.com/websphere/) Books from MC Press (http://MCPressOnline.com)Books from MC Press (http://MCPressOnline.com) Training from IBM and TLCC (http://tlcc.com) Training from IBM and TLCC (http://tlcc.com) HeadFirst Java and HeadFirst EJB from O’Reilly HeadFirst Java and HeadFirst EJB from O’Reilly

(http://HeadFirstJava.com) (http://HeadFirstJava.com)

Page 20: Developing a Struts & Tiles application using WebSphere Studio

Looking towards the futureLooking towards the future Plan on continuing to refine and Plan on continuing to refine and

expand directory application and expand directory application and offer it for freeoffer it for free

Other technologies: JSTL, Using XML Other technologies: JSTL, Using XML & XSLT instead of JSPs, JavaServer & XSLT instead of JSPs, JavaServer Faces and moreFaces and more

EJBs, Web Services, J2EE 1.4, EJBs, Web Services, J2EE 1.4, WebSphere Portal, DB2, UML, etc.WebSphere Portal, DB2, UML, etc.

Page 21: Developing a Struts & Tiles application using WebSphere Studio

Questions?Questions? Sample code available at Sample code available at

http://DanVelasco.com/exampleshttp://DanVelasco.com/examples WebSphere tips at WebSphere tips at

http://WebSpherePower.comhttp://WebSpherePower.com Website: Website: http://DanVelasco.comhttp://DanVelasco.com E-mail: E-mail: [email protected]@zatz.com