e Purchasing System using Struts Framework Java Administration














































![Using Natural Broker public String[][] get. Balance(String document) throws IOException { … String broker. Using Natural Broker public String[][] get. Balance(String document) throws IOException { … String broker.](https://slidetodoc.com/presentation_image_h2/46d9e5816b16cda25ec67d098c924667/image-47.jpg)





- Slides: 52

e. Purchasing System using Struts Framework Java Administration Special Interest Group December 9, 2002 Mimpin Halim University of Hawai’i

Presentation Goals § § Introduce UH e. Purchasing System from 1, 001 miles away Highlight e. Purchasing requisition processing steps Benefits and Limitations of using Struts Introduce backend technologies from even further away

e. Purchasing Goals § § Mitigate risk by reducing human errors Shorter turn-around time Shift employees' focus from paperwork to productivity Use information more efficiently by integrating enhanced transaction data with the existing systems § Reduce cost of papers § Transition to completely paperless purchasing system

University of Hawai’i e. Purchasing System Overview § Supports requisition, purchase order change, invoice and payment processing § Provides electronic approvals § Supports multiple user roles with varied access to the system features using LDAP authentication § Validates accounts for activity and available budget

University of Hawai’i e. Purchasing System Overview (cont. ) § Integrated with Super. QUOTE™ from Commerce. Point § Supports real-time encumbering of purchases and real-time posting of payment expenditures § Handles the creation, modification and storage/retrieval of purchasing documents. § Built using Struts Framework v 1. 0 in transition to v 1. 1

e. Purchasing Implementation § § § System development started in August 2001 System was implemented in December 2001 Currently in phased development and release cycles

e. Purchasing Statistics § As of November 5, 2002: q 38 out of 58 units implemented q 585 out of ± 800 users q 3, 891 processed purchase orders q 3, 767 payments q $8, 547, 487. 60 processed purchases

e. Purchasing Document flow of Requisition & Purchase Order

Requisition Document Flow from Business Logic Perspective

Purchase Order Document Flow from Business Logic Perspective § § Account access validation Encumbrance posting

e. Purchasing Screen Captures

e. Purchasing Login

e. Purchasing Main Menu

e. Purchasing Pending Requisitions

e. Purchasing New Requisition Form

e. Purchasing Requisition Submission

e. Purchasing Requisition Transfer

e. Purchasing Purchase Order Form

e. Purchasing Hardcopy Purchase Order

Let’s talk about Struts!

Struts Overview § Open source framework for building web applications created by Craig Mac. Clanahan. § Donated to Apache Software Foundation (ASF) in 2000 § Provides extensible development environment § Based on standard technologies like Java Servlets, Java. Beans, Resource. Bundles and XML § Based on Model 2 architecture, a variation of MVC design paradigm

Benefits of using Struts from Management perspective § § § Open Source Good documentation Stable and Mature Developed by industry experts Manageable learning curve Large user community

Benefits of using Struts from Developer perspective § Highly customizable § Feature-rich § Extendable and flexible § Widely supported with many free third party tools § Solid design with good documentation § Large user community with very active mailing list § Provides good separation between presentation and business logic. § Modular architecture promotes easier development

Limitations of using Struts from Developer perspective § Building large and complicated form § Lack of “dynamic properties” § Complicated client-side form/Java. Script interaction § Last two limitation have been addressed in Struts 1. 1

Struts Framework Features § Supports internationalization - I 18 N § Database support and JDBC Connection pooling capabilities § Compatible with a variety of model implementations - EJB, Java. Beans, CORBA, etc. § Compatible with a varietiy of presentation layers - JSP, XML/XSLT, etc. § Write once, run anywhere philosophy

Struts Environment § Java Software Development Kit 1. 2 or higher § Servlet 2. 2/JSP 1. 1 container or higher § XML parser compliant with JAXP 1. 1 or higher

Inside Struts Framework § Controller § Model § View

Struts implementation of MVC in e. Purchasing Architecture

Controller

Controller : Components § Action. Servlet § Request. Processor § Action Classes

Controller : Action. Servlets § Extends <javax. servlet. http. Http. Servlets> § Receives all framework requests § Selects proper application module § Delegates request handling to the Request. Processor instance § One instance per web application § Default implementation provided by framework

Controller : Request. Processor § One instance per web application module § Processes all request for module § Invokes proper Action instance § Default implementation provided by framework

Controller : Action Classes § Extends <org. apache. struts. action. Action> § In Struts 1. 0 overrides the perform() method § In Struts 1. 1 overrides the execute() method § Acts as a bridge between user-invoked URI and a business method § Provides information about which view should be rendered and returned

Example of Action. Mapping <!-- Initial requisition form with user defaults --> <struts-config> … <action-mappings type="org. apache. struts. action. Action. Mapping"> … <!-- Initial requisition form with user defaults --> <action path="/new. Req. Init" type="edu. hawaii. purchasing. New. Req. Init. Action" name="req. Form" scope="request" attribute="req. Form"> <forward name="success" path="/jsp/req. Form. jsp" /> </action> … </action-mappings> </struts-config>

Requisition Document Flow from Business Logic Perspective

The Journey of Requisition with Action URI

Example of Action Class public class New. Req. Action extends Action { public Action. Forward perform(Action. Mapping mapping, Action. Form form, Http. Servlet. Request request, Http. Servlet. Response response) throws IOException, Servlet. Exception { // Check if user logged in // (can be implemented by extending Request. Processor) Http. Session session = request. get. Session(false); Login. Model login. Model = new Login. Model(); if (!login. Model. is. Logged. In(session)) { Action. Forward login = mapping. find. Forward("login"); login. set. Redirect(true); return login; }…

Example of Action Class (cont. ) … // Get User’s information String user. ID = (String) session. get. Attribute("user. ID"); User. Bean user. Bean = User. Model. get. User. Info(user. ID); user. Bean. set. First. Name((String) session. get. Attribute("first. Name")); user. Bean. set. Last. Name((String) session. get. Attribute("last. Name")); user. Bean. set. Middle. Initial((String) session. get. Attribute("middle. Initial")); Req. Model req. Model Req. Bean req. Bean Vndr. Bean vndr. Bean req. Bean = = new Req. Model(); new Req. Bean(); new Vndr. Bean(); (Req. Bean) req. Model. init(user. Bean, vndr. Bean, req. Bean); request. set. Attribute("req. Bean", req. Bean); return (mapping. find. Forward("success")); } // perform() } // eof: New. Req. Action

Model

Model : Facts § No model components provided § Struts supports any model component - EJB, Corba, Java. Beans, etc § Decouple model implementation from the framework

Model Component of e. Purchasing § Java Data Base Connectivity (JDBC 2. 0) with Oracle Database utilizing Poolman Connection Pooling. § Entire. X Java ACI v 5. 2. 1. 0 by Software AG to tap into the IBM Mainframe for Remote Procedure Call.

Example of Model Class public class User. Model { private static Category logger = Category. get. Instance(User. Model. class. get. Name()); public static User. Bean get. User. Info(String user. ID) throws IOException { Connection conn = null; Statement stmt = null; Result. Set rs = null; try { conn = Driver. Manager. get. Connection( Properties. Loader. get. Property("oracle. datasource")); stmt = conn. create. Statement();

Example of Model Class (cont. ) // SQL Statement String col. Names = "dept, deliv_addr_1, deliv_addr_2, deliv_addr_3, " + “deliv_addr_4, deliv_city, deliv_st, deliv_zip, …”; String table. Name = "fmis_user "; String sql. Stmt = "select " + col. Names + "from " + table. Name + "where user_id = '" + user. ID + "'"; rs = stmt. execute. Query(sql. Stmt); User. Bean user = new User. Bean(); while (rs. next()) { user. set. Deliv. Dept(rs. get. String("dept")); user. set. Deliv. Addr 1(rs. get. String("deliv_addr_1")); user. set. Deliv. Addr 2(rs. get. String("deliv_addr_2")); … } return user; } … //catch exception and finally close Result. Set, Statement, Connection

Invoker Action Class … // Get User’s information String user. ID = (String) session. get. Attribute("user. ID"); User. Bean user. Bean = User. Model. get. User. Info(user. ID); user. Bean. set. First. Name((String) session. get. Attribute("first. Name")); user. Bean. set. Last. Name((String) session. get. Attribute("last. Name")); user. Bean. set. Middle. Initial((String) session. get. Attribute("middle. Initial")); Req. Model req. Model Req. Bean req. Bean Vndr. Bean vndr. Bean req. Bean = = new Req. Model(); new Req. Bean(); new Vndr. Bean(); (Req. Bean) req. Model. init(user. Bean, vndr. Bean, req. Bean); request. set. Attribute("req. Bean", req. Bean); return (mapping. find. Forward("success")); } // perform() } // eof: New. Req. Action

Struts Action. Mapping <!-- Initial requisition form with user defaults --> <struts-config> … <action-mappings type="org. apache. struts. action. Action. Mapping"> … <!-- Initial requisition form with user defaults --> <action path="/new. Req. Init" type="edu. hawaii. purchasing. New. Req. Init. Action" name="req. Form" scope="request" attribute="req. Form"> <forward name="success" path="/jsp/req. Form. jsp" /> </action> … </action-mappings> </struts-config>

Model : Natural Broker § Execute Remote Procedure Call to specific Broker program running in the Mainframe § Call is sent to the Broker as a String containing program name, parameters needed for the program to execute § Return user-defined number of bytes in the form of byte arrays § Can do more than one invocation with a given open connection to the host running the Entire. X Broker server
![Using Natural Broker public String get BalanceString document throws IOException String broker Using Natural Broker public String[][] get. Balance(String document) throws IOException { … String broker.](https://slidetodoc.com/presentation_image_h2/46d9e5816b16cda25ec67d098c924667/image-47.jpg)
Using Natural Broker public String[][] get. Balance(String document) throws IOException { … String broker. Parms = "JWSPEBAL 28000" + document + fis. Year; int receive. Buffer. Size = 28000; byte[] reply. Array = null; String[][] acct. Balances = new String[1][5]; Broker. Message b. Reply = nb. perform(broker. Parms, receive. Buffer. Size); if (b. Reply == null) { if (logger. is. Debug. Enabled()) { logger. debug("get. Balance() - No results"); } return acct. Balances; } else { …

Using Natural Broker (cont. ) reply. Array = nb. get. Results(b. Reply); String count = new String(reply. Array, 0, 2); int acct. Count = Integer. parse. Int(count); if (acct. Count == 0) { return acct. Balances; } acct. Balances = new String[acct. Count][5]; // each account has 5 properties for (int i = 0; i < acct. Count; i++) { int r. Offset = 2 + (i * 40); acct. Balances[i][0] = new String(reply. Array, acct. Balances[i][1] = new String(reply. Array, acct. Balances[i][2] = new String(reply. Array, acct. Balances[i][3] = new String(reply. Array, acct. Balances[i][4] = new String(reply. Array, … r. Offset, 2); r. Offset + 2, 6); r. Offset + 8, 4); r. Offset + 12, 14); r. Offset + 26, 14); // // // campus account subcode curr. amt liq. amt

View

View : Components § Java Server Pages § HTMLs § Java. Scripts and Style. Sheets § Resources Bundles § Java. Beans extending Action. Forms § Custom Tags - HTML, Bean, Logic

Future Improvements § Upgrade to Struts 1. 1 § Utilize Validators and Tiles from Struts 1. 1 § Use XML/XSLT for View Component What’s new in 1. 1? http: //jakarta. apache. org/struts/user. Guide/release-notes-1. 1 -b 2. html

Questions?