CIS 764 Tutorial: Log-in Application

Similar documents
Prototype 1.0 Specification

TUTORIAL: ADF Faces (Part 1-Modified) Passing parameter values between JSF pages By: Dr.Ahmad Taufik Jamil, Pusat Teknologi Maklumat, HUKM

Oracle Developer Day

Quick Web Development using JDeveloper 10g

Oracle WebCenter Suite Integrating Secure Enterprise Search

ADF Mobile Code Corner

Developing Applications with Java EE 6 on WebLogic Server 12c

Oracle Fusion Middleware 11g: Build Applications with ADF I

Oracle Developer Day

Oracle 10g: Build J2EE Applications

Oracle Retail Accelerators for WebLogic Server 11g

Oracle ADF: The technology behind project fusion. Lynn Munsinger Principal Product Manager Application Development Tools Oracle Corporation

KSU Student Portal. MSE Project Final Presentation. Javier Ramos Rodríguez

ADF Hands-On. Understanding Task Flow Activities / 2011 ADF Internal Enterprise 2.0 Training. Abstract:

User Manual. KSU Student Portal. Version 1.0. Submitted in partial fulfillment of the requirements of the degree of MSE

Oracle Fusion Middleware 11g: Build Applications with ADF I

J2EE Development. Course Detail: Audience. Duration. Course Abstract. Course Objectives. Course Topics. Class Format.

Rational Application Developer 7 Bootcamp

Oracle - Developing Applications for the Java EE 7 Platform Ed 1 (Training On Demand)

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

Developing an ADF 11g client for Agile PLM. Developing an ADF 11g client for Agile PLM

User s Guide 12c (12.2.1)

CIS 764 Tutorial. By Vamsee Raja Jarugula.

HYPERION SYSTEM 9 BI+ GETTING STARTED GUIDE APPLICATION BUILDER J2EE RELEASE 9.2

Oracle Enterprise Pack for Eclipse

open source community experience distilled

Oracle Application Development Framework Overview

NetBeans IDE Field Guide

ADF Code Corner How-to build a reusable toolbar with Oracle ADF Declarative Components. Abstract: twitter.com/adfcodecorner

Creating your first JavaServer Faces Web application

CHAPTER. Introduction to the Oracle Application Development Framework

Oracle Developer Day

Dreamweaver MX The Basics

Oracle Fusion Middleware 11g: Build Applications with Oracle Forms

Departamento de Engenharia Informática. Systems Integration. SOA Adapters Tutorial. 1. Open SQL*Plus in order to run SQL commands.

Managing Your Database Using Oracle SQL Developer

How to Develop a Simple Crud Application Using Ejb3 and Web Dynpro

Enterprise Integration

Java EE 6: Develop Web Applications with JSF

Oracle 1Z Oracle WebCenter 11g Essentials.

Courses For Event Java Advanced Summer Training 2018

MindTelligent, Inc. EJB 2.0 Design and Development with JDeveloper 9i and stand alone OC4J (Oracle Components for Java) A Technical White Paper.

Oracle Fusion Middleware 11g: Build Applications with ADF Accel

Table of contents. Zip Processor 3.0 DMXzone.com

J2EE - Version: 25. Developing Enterprise Applications with J2EE Enterprise Technologies

BEAWebLogic. Portal. Tutorials Getting Started with WebLogic Portal

ADF Code Corner How-to bind custom declarative components to ADF. Abstract: twitter.com/adfcodecorner

ADF Mobile Code Corner

Oracle Fusion Middleware

Departamento de Engenharia Informática. Systems Integration. Web Services and BPEL Tutorial

Standard Edition (SE) application development Enterprise Edition (EE) enterprise development Micro Edition (ME) Internet of Things (IoT) development

Oracle Developer Day

Oracle Fusion Middleware 11g: Build Applications with Oracle Forms

Chapter 2 FEATURES AND FACILITIES. SYS-ED/ Computer Education Techniques, Inc.

Oracle Fusion Middleware

JSF Tools Reference Guide. Version: M5

(800) Toll Free (804) Fax Introduction to Java and Enterprise Java using Eclipse IDE Duration: 5 days

Lyudmil Pelov, A-Team, Oracle December Development Lifecycle for Task Flows in Oracle WebCenter Portal 11gR1 version

Doc. Version 1.0 Updated:

Overview. Principal Product Manager Oracle JDeveloper & Oracle ADF

A Closer Look at XPages in IBM Lotus Domino Designer 8.5 Ray Chan Advisory I/T Specialist Lotus, IBM Software Group

Sun Java Studio Creator. Ken Paulsen Staff Engineer Sun Microsystems, Incorporated (Slides by: Craig R. McClanahan)

Oracle Fusion Middleware

Lookup Transformation in IBM DataStage Lab#12

Website Pros Database Component. v

UNIVERSITY OF MUMBAI. OCTOBER 2014 ADVANCED JAVA Seat No. : Max. Marks: 50

DbSchema Forms and Reports Tutorial

Oracle Fusion Middleware 11g: Build Applications with Oracle Forms

If you wish to make an improved product, you must already be engaged in making an inferior one.

ADF Code Corner. 70. How-to build dependent list boxes with Web Services Business Services. Abstract: twitter.com/adfcodecorner

J2EE AntiPatterns. Bill Dudney. Object Systems Group Copyright 2003, Object Systems Group

JBuilder. Getting Started Guide part II. Preface. Creating your Second Enterprise JavaBean. Container Managed Persistent Bean.

DbSchema Forms and Reports Tutorial

Oracle WebCenter Hands-On Practices. A Practical Introduction to Oracle WebCenter

Enterprise Integration

ADF Code Corner How-to declaratively build a master-detail behavior with DVT components. Abstract: twitter.com/adfcodecorner

Java EE 7: Back-End Server Application Development

ADF Code Corner How-to use the af:autosuggestbehavior component tag with ADF bound data sources. Abstract: twitter.

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

Skyway Builder 6.3 Reference

The purpose of this tutorial is to introduce you to the Construct 2 program. First, you will be told where the software is located on the computer

Seam Tools Tutorial. Version: Final-SNAPSHOT

LEARN TO DEVELOP A LIVE PROJECT AS PER IT STANDARDS. Module 1: What we are going to Learn. Prerequisites

ADF Code Corner. 90. Filtering ADF bound lists. Abstract: twitter.com/adfcodecorner

Extensibility Guide Oracle Financial Services Lending and Leasing Release [October] [2013] Part No. E

1. INTRODUCTION to Object Storage

Tutorial. Interactive Forms Integration into Web Dynpro for Java Topic: Working with the PdfObject API

OSR Composer 3.7 User Guide. Updated:

Orgnazition of This Part

ADF Mobile Code Corner

Oracle Fusion Developer Guide (ISBN: ) Preview Chapter 1. The Quick Lerner s Guide to Oracle Fusion Web Application Development PREVIEW

JBoss SOAP Web Services User Guide. Version: M5

Oracle Middleware 12c: Build Rich Client Applications with ADF Ed 1 LVC

Table of contents. Pure ASP Upload 3 Manual DMXzone

J2EE Access of Relational Data

Standard Edition (SE) application development Enterprise Edition (EE) enterprise development Micro Edition (ME) Internet of Things (IoT) development

Advanced Java Programming

More Skills 11 Export Queries to Other File Formats

Table of contents. DMXzone Ajax Form Manual DMXzone

SUN Sun Certified Enterprise Architect for J2EE 5. Download Full Version :

Transcription:

CIS 764 Tutorial: Log-in Application Javier Ramos Rodriguez Purpose This tutorial shows you how to create a small web application that checks the user name and password. Overview This tutorial will show how to use the EJB 3.0 specification and the Java Server Faces (JSF) in Jdeveloper. We will show that JSF are very useful to validate the inputs. Scenario In this tutorial we ll create a persistence object Student from a table STUDENT. We will create a session bean to manage the entity object (entity bean) and we ll use JSF as View-Controller. Prerequisites You ll need to have access to an Oracle Database and the Jdeveloper 10g IDE. You also need a connection to the database. 1

Step 1. Creating the STUDENT table. 1. Open the Jdeveloper and on the navigator select connections. Then, go to the Oracle database connection and right-click on SQLworksheet. 2. In the SQL worksheet window, copy and paste this SQL code: create table STUDENT ( login varchar2(50) primary key, passwd varchar2(50) NOT NULL, name varchar2(90) NOT NULL, email varchar2(90) NOT NULL); 2

3. Click on the Execute SQL Statement button and the query will be executed. Step 2. Configuring the Application In this section we will create the persistence object using entity beans. 1. In JDeveloper, click the Applications tab. In the Applications navigator, right-click Applications and select New Application from the shortcut menu. 3

2. In the Create Application dialog box, enter JSFLoginTutorial as the application name, and select the JSF, JSP, EJB template option. Click OK. 4

3. In the JSFLoginTutorial application, right-click in ViewController project and then click on properties. 4. Choose Dependences tab and click on the Model. 5

6

Step 3. Creating the Persistence Model 1. In the Applications navigator, right-click the JSFLoginTutorial node and choose the New option. 2. In the New Gallery dialog box, expand the Business Tier node in Categories. In the Items list, select CMP Entity Beans from tables. Click OK. 7

3. Click Next on the Welcome page of the "Create CMP Entity Beans from Tables" wizard. In Step 1 of 5, select the Enterprise JavaBeans 3.0 (J2EE 5.0) option, and then click Next. 4. In Step 2 of 5, select the Oracle connection as the connection name. 8

5. In step 3 of 5, click the Query button, and then select the STUDENT table from the Available list and shuttle them to the Selected list. Click Next. 6. In step 4 of 5, enter model as the package name. Click Next. 9

7. Click Next in step 5 of 5 and then Finish to create the entity beans. 10

Step 4. Creating the Business Model 1. Right-click the JSFLoginTutorial project node in the Applications navigator and select the New option from the context menu. Open the Business Tier category and choose the Session Bean item. Click OK. 11

2. Click Next on the Welcome page of the Create Enterprise JavaBean wizard. In step 1 of 3, enter StudentSessionEJB as the EJB name. Leave the options unchanged, and then click Next. 3. Leave everything unchanged in steps 2 and 3 and click Finish. 12

4. Open the StudentSessionEJB file in the navigator and add the next method. public boolean checklogin(string login, String passwd) throws NamingException { return getentitymanager().createquery( "select object(o) from Student o where ((o.login LIKE :login) AND (o.passwd LIKE :passwd))").setparameter("login", login).setparameter("passwd", passwd).getresultlist().isempty(); } This will query the database to check if the login and password given by the user are in the database. 5. Open the StudentSessionEJB interface and add the methods declarations. boolean checklogin(string login, String password) throws NamingException; 13

6. Right-click in StudentSessionEJBBean and click on New Sample Java Client. 14

7. In Client Class name write model.modelfacade and click ok. 8. Delete the main method and create the next method that is going to check if the login and password are stored in the database. public boolean checklogin(string login, String password) { boolean check = true; try { final Context context = getinitialcontext(); StudentFacade studentfacade = (StudentFacade) context.lookup("studentfacade"); check = studentfacade.checklogin(login, password); // true empty resutls } catch (NamingException e) { e.printstacktrace(); } } return!check; 15

Step 5. Create the Control-Flow Diagram 1. In the application navigator, select the ViewController project and in the WenContent\WEB_INF folder open the faces-config.xml file. 2. In the editor, drag and drop a JSF page from the component palette. Change the name to login.jsp. Then, drag and drop another JSF page to the diagram and change the name to main.jsp. Finally, drag and drop the JSF Navigation Case component from the palette and connect the login.jsp page to the main.jsp page. Change the name to go_main. 16

Step 6. Create the JSF pages. 1. Double-click in the login.jsp page in the diagram. The Create JSF JSP Wizard Welcome screen displays. Click Next to continue. In step 1, leave everything unchanged. 2. In Step 2, choose Automatically Bind Components Using a Newly Created Managed Bean. 17

3. In Step 3, Choose not to use error page. 4. In Step 4, choose the default libraries, JSF Core and JSF HTML. 18

5. In Step 5, Choose the page title. Click next and then finish. 19

Step 7. Edit the JSP page. 1. The JSP editor will appear. In the top of the page enter some text: Welcome. Format the text to H1 by clicking the left-hand dropdown list at the top of the Visual Editor, and choosing Heading 1. Then, apply a CSS style sheet. Select the CSS page in the Components section in the top right of your screen. Then drag the JDeveloper style sheet onto your new JSP. You should see an immediate change in the appearance of you page. 2. In the Component palette choose JSF HTML and click on Panel Grid. In the new window choose 2 in number of columns and click finish. 20

3. Now drag and drop the next components one after the other as show in the figure: OutputLabel, InputText, OutputLabel, InputSecret, CommandButton and Messages. 4. Change the outputlabel1 name to Login and the outputlabel2 name to Password. Also, change the commandbutton name to Submit, to do this go to the property inspector window and change the value label. 21

Step 8. Implementing the behavior 1. Double click in the Submit button. The Login.java file will open to edit the action. Copy and paste the next code: public String commandbutton1_action() { boolean check = false; String message = new String(); String login = inputtext1.getvalue().tostring(); String passwd = inputsecret1.getvalue().tostring(); if ((login.length() < 4) (passwd.length() < 4)) { message = "Invalid inputs"; } else { ModelFacade check_log = new ModelFacade(); } if (!check_log.checklogin(login, passwd)) { message = "Wrong username or password"; } else { check = true; } FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(message)); } if (check) { return "go_main"; } else { return "failure"; } This code will check that the inputs are valid and also will ask the model to check if the username and password are valid. 22

2. Import the model.modelfacade package. 23

Step 9. Create the main page and run the application. 1. Double click in main.jsp in the JSF navigation flow diagram. Create the JSP page like before and it will open in the editor. Enter some text and apply the style sheet. 2. Right-Click in the login.jsp page and then run. 24

Main Page: 25