11 Copyright © 2004, Oracle. All rights reserved. Customizing Actions.

Slides:



Advertisements
Similar presentations
4 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: Servlets.
Advertisements

8 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: JavaServer Pages.
6 Copyright © 2005, Oracle. All rights reserved. Building Applications with Oracle JDeveloper 10g.
17 Copyright © 2005, Oracle. All rights reserved. Deploying Applications by Using Java Web Start.
Struts Portlet Adding an Action Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without.
Web Development with Karsten Schulz Terp-Nielsen Master Principal Sales Consultant Oracle Denmark.
Apache Struts Technology
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
MVC Frameworks Alternatives to coding the MVC pattern.
Struts1 Apache Struts Dr Jim Briggs. Struts2 What is Struts? Struts is an open source framework for building Java web applications Supports MVC/Model.
Struts Basics SSE USTC Qing Ding. Agenda What is and Why Struts? Struts architecture – Controller: Focus of this presentation – Model – View Struts tag.
Objectives:1. Investigate the Web application deployment descriptor 2. Install and deploy Tomcat and struts 3. Design and deploy a struts application Struts.
Apache Struts Technology A MVC Framework for Java Web Applications.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
Building an application … with Struts! Presented by Ted Husted [ ]
Struts 2.0 an Overview ( )
Struts:The good, the bad, the ugly A detailed evaluation of Struts 1.1 and Enterprise Web Applications. By Paul Smith Ancept, Inc. (
Michael Rimov Centerline Computers Craig McClanahan Sun Microsystems O’Reilly Open Source Convention July , 2003.
UNIT-V The MVC architecture and Struts Framework.
Lecture 2 - Struts ENTERPRISE JAVA. 2 Contents  Servlet Deployment  Servlet Filters  Model View Controllers  Struts  Dependency Injection.
Author: DoanNX Version 2.0/Time: 30’. The ways to solve it There are 2 main ways:  Client-side: Using JavaScript (now one very good option is JQuery).
Copyright © 2012 Accenture All Rights Reserved.Copyright © 2012 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are.
Introduction to MVC and the Jakarta Struts Framework By Gyanendra Dwivedi Software Consultant.
Basic Struts Architecture Client Server Database Request Response Control View Model Server Struts Framework.
Jakarta Struts Presented by Object Computing, Inc. (OCI) Written by Greg Elliott
Standalone Java Application vs. Java Web Application
CGS – 4854 Summer 2012 Web Site Construction and Management Instructor: Francisco R. Ortega Chapter 2.
8/15/2003System Specialists Corporation How to implement BC4J with the Struts Framework Eugene Sicat Technical Architect/Project Manager System Specialists.
Struts J2EE web application framework “ Model 2 ” Model View Controller Controller Servlet Key features XML metadata Struts taglib Simplified form validation.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
© 2011 IBM Corporation MDD Support for Struts in RSA  Helps accelerate Struts Application development  Architects can communicate Struts application.
How to Build a Struts Application with JBuilder 9.
BOF # The Struts Framework Community The Struts Framework Community Craig McClanahan.
Copyright Ó Oracle Corporation, All rights reserved Working with Other Canvases.
Struts Framework Anna Paščenko. What is Struts?  An open source framework for building Java web applications.
REVOLUTION TO NEXT GENERATION Struts2.0 20/02/ Avishek Arang ::
J2EE Struts 1 3 Struts: Introduction 1 4 Once you’ve coded a lot of JSP applications, you find yourself doing a lot of repetitive things. Also,
CSC 2720 Building Web Applications Frameworks for Building Web Applications.
Page 1 Controller Action2.java Struts- config. xml Mappings Business Logic Layer Data Layer View Layer Business Bean 1 Jsp Engine Jsp 1 Action3.java Action4.java.
JSP Pages. What and Why of JSP? JSP = Java code imbedded in HTML or XML –Static portion of the page is HTML –Dynamic portion is Java Easy way to develop.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
1 Copyright © 2004, Oracle. All rights reserved. Oracle Application Development Framework.
13 Copyright © 2004, Oracle. All rights reserved. Adding Validation and Error Handling.
Struts Framework Day-2 Ashok Chakravarti. DataSource Usage Sample Struts-config.xml …
14 Copyright © 2004, Oracle. All rights reserved. Enhancing the User Interface.
Implementation Struts Framework for well-architectured web applications Model-View-Controller design pattern.
15 Copyright © 2004, Oracle. All rights reserved. Adding JAAS Security to the Client.
8 Copyright © 2004, Oracle. All rights reserved. Making the Model Secure.
 Java Server Pages (JSP) By Offir Golan. What is JSP?  A technology that allows for the creation of dynamically generated web pages based on HTML, XML,
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
22 Copyright © 2009, Oracle. All rights reserved. Filtering Requests in Oracle Business Intelligence Answers.
APACHE STRUTS ASHISH SINGH TOMAR ast2124. OUTLINE Introduction The Model-View-Controller Design Pattern Struts’ implementation of the MVC Pattern Additional.
2 Copyright © 2004, Oracle. All rights reserved. ADF Development Process.
Copyright Ó Oracle Corporation, All rights reserved. 77 Creating LOVs and Editors.
12 Copyright © 2004, Oracle. All rights reserved. Using ADF Struts Components.
17 Copyright © 2004, Oracle. All rights reserved. Integrating J2EE Components.
Apache Struts Technology A MVC Framework for Java Web Applications.
3 Copyright © 2006, Oracle. All rights reserved. Building an Analytic Workspace.
Copyright Ó Oracle Corporation, All rights reserved. 88 Creating Additional Input Items.
1 Copyright © 2008, Oracle. All rights reserved. Repository Basics.
CS 562 Advanced Java and Internet Application Computer Warehouse Web Application By Team Alpha :-  Puja Mehta (102163)  Mona Nagpure (102147)
V Web Tier Architecture MVC and Struts. v First, there were servlets And things were good Faster than CGI programs More scalable with built-in.
2 Copyright © 2008, Oracle. All rights reserved. Building the Physical Layer of a Repository.
An Introduction to and This document is for purely educational purposes.
19 Copyright © 2008, Oracle. All rights reserved. Security.
Handling Errors in Web Applications
Java Servlets By: Tejashri Udavant..
Controlling an Application with Struts
Unit 6-Chapter 2 Struts.
Presentation transcript:

11 Copyright © 2004, Oracle. All rights reserved. Customizing Actions

11-2 Copyright © 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Describe the Struts XML elements and structure Describe the anatomy of an action Use the execute method to enhance the behavior of an action Describe the use of form beans Use a dynamic form bean

11-3 Copyright © 2004, Oracle. All rights reserved. Struts Configuration File Is XML type file Is the application resource descriptor Is used by the servlet to determine actions to perform

11-4 Copyright © 2004, Oracle. All rights reserved. Creating the Action Class In the context menu, select “Go to Code.” Or, double-click the action. Specify a name for the action. /auth

11-5 Copyright © 2004, Oracle. All rights reserved. Default Code of an Action public class AuthUserAction extends Action { /* This is the main action called from the Struts framework.*/ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { return mapping.findForward("success"); } }

11-6 Copyright © 2004, Oracle. All rights reserved. Forwards Forwards can be defined: By using the Page Flow Diagram In the XML file In the Structure pane /authUser success failure /page1 /page2

11-7 Copyright © 2004, Oracle. All rights reserved. ActionForward of an Action Class The return parameter from ActionForward specifies where to send control. The default naming of a single forward is success. The execute() method can be customized: –Additional code can be added. –Other forwards can be specified. –Appropriate forward is done on conditional testing. The forward name represents a logical name. A forward can also be a global forward.

11-8 Copyright © 2004, Oracle. All rights reserved. Creating Global Forwards A global forward is just like any forward, but it can be accessed by any action. The global forward is defined in the config file. The global forward is specified in the action class. return mapping.findForward("help");

11-9 Copyright © 2004, Oracle. All rights reserved. Form Beans User Name Password Logon logonBean Submit Logon authUser menu Populates

11-10 Copyright © 2004, Oracle. All rights reserved. Form Beans A form bean is used to transport data between a page and an action. Can be static: –Is defined in a FormBean class –Contains set(), get(), and reset() methods for each field –Contains a validate() method for verifying user input Can be dynamic: –Each field specified in struts.config.xml –Does not require Java code

11-11 Copyright © 2004, Oracle. All rights reserved. Creating a Static Form Bean Create an action in the Page Flow Editor. Right-click and select “Go to Form Bean.” Specify a name (suffix the name with “Form”). A new icon is displayed. /authUser

11-12 Copyright © 2004, Oracle. All rights reserved. Example: Static Form Bean public class AuthUserActionForm extends ActionForm { String username; public String getUsername() { return username; } public void setUsername(String newUsername) { username=newUsername; } public void reset( … public ActionErrors validate( … }

11-13 Copyright © 2004, Oracle. All rights reserved. Dynamic Form Beans This is an alternative way for an action to have access to incoming fields from a page. The form bean class is not needed. There is no need for getter and setter methods. The field names are specified in the struts- config.xml file. New fields can be added dynamically.

11-14 Copyright © 2004, Oracle. All rights reserved. Creating a Dynamic Form 1.Create a form bean from the Structure pane. 2.Specify org.apache.struts.action.DynaActionForm as the type for the bean. 3.Create a new form property for each field.

11-15 Copyright © 2004, Oracle. All rights reserved. Using the Bean in an Action Using a static bean: –Create and cast the ActionForm type –Use the getXxx() method Using a dynamic bean: –Cast the form object passed to the execute() method to a DynaActionForm type AuthUserActionForm authForm = (AuthUserActionForm) form; String username=authForm.getUsername(); String username=(String)((DynaActionForm)form).get("username");

11-16 Copyright © 2004, Oracle. All rights reserved. Sample Page Flow success failure <action path="/authUser" name="logonBean" type="view.AuthUserAction"> Logon authUser menu

11-17 Copyright © 2004, Oracle. All rights reserved. Sample Page Flow: Struts Elements <action path="/authUser" name="logonBean" type=" view.AuthUserAction "> success failure Logon authUser menu

11-18 Copyright © 2004, Oracle. All rights reserved. <action path="/authUser" name="logonBean" type=" view.AuthUserAction "> Sample Page Flow: Struts Elements success failure Logon authUser menu

11-19 Copyright © 2004, Oracle. All rights reserved. Sample Page Flow: Form Bean User Name Password Logon logonBean Submit success failure Logon authUser menu

11-20 Copyright © 2004, Oracle. All rights reserved. Sample Page Flow: Form Bean <form-bean name="logonBean“ type="org.apache.struts. action.DynaActionForm"> success failure Logon authUser menu

11-21 Copyright © 2004, Oracle. All rights reserved. Sample Page Flow Passed to User Name Password Logon logonBean Submit Populates success failure Logon authUser menu

11-22 Copyright © 2004, Oracle. All rights reserved. Sample Page Flow: Action Class public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { DynaActionForm LAF = (DynaActionForm) form; String un = (String)LAF.get("username"); String pw = (String)LAF.get("password"); if (un.equals("Scott")) { return mapping.findForward("success"); } else return mapping.findForward("failure"); }

11-23 Copyright © 2004, Oracle. All rights reserved. Sample Page Flow Passed to User Name Password Logon logonBean Submit Populates success failure Logon authUser menu

11-24 Copyright © 2004, Oracle. All rights reserved. Form Beans, Data Actions, and Data Pages ADF creates a form bean automatically when you create: –Data actions –Data pages The ADF Form Bean is called a DataForm. DataForms do not require custom code: –No static form bean class is needed. –No dynamic form bean declaration is needed. ADF uses these objects to manage form data.

11-25 Copyright © 2004, Oracle. All rights reserved. Summary In this lesson, you should have learned how to: Describe the Struts XML elements and structure Describe the anatomy of an action Use the execute method to enhance the behavior of an action Describe the use of form beans Use a dynamic form bean

11-26 Copyright © 2004, Oracle. All rights reserved. Practice 11-1: Overview This practice covers the following topics: Using the Page Flow Diagram Adding data actions Adding data pages Creating form beans

11-27 Copyright © 2004, Oracle. All rights reserved. Practice 11-1

11-28 Copyright © 2004, Oracle. All rights reserved. Practice 11-1

11-29 Copyright © 2004, Oracle. All rights reserved. Practice 11-1

11-30 Copyright © 2004, Oracle. All rights reserved. Practice 11-1