JSF Portlet Backing Beans and UI Components Copyright © 2000-2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in.

Slides:



Advertisements
Similar presentations
15 Copyright © 2005, Oracle. All rights reserved. Adding User Interface Components and Event Handling.
Advertisements

17 Copyright © 2005, Oracle. All rights reserved. Deploying Applications by Using Java Web Start.
Servlet-JSP and HtmlFixture exercise and solution
JSP and web applications
Struts Portlet Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Struts Portlet Adding an Action Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without.
Web Services Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Apache Struts Technology
Internet Technologies 1 Master of Information System Management Java Server Faces Model/View/Controller Design Pattern for Web Development Slides.
JavaServer Faces. Objectives To implement dynamic web pages with JavaServer Faces (JSF) technology To learn the syntactical elements of JavaServer Faces.
Java Server Faces Model/View/Controller Design Pattern for Web Development Slides adapted from “Core JavaServer Faces” by Geary and Horstmann and the J2EE.
Create a New Application and Project Open the Create Application dialog. Enter the application name of your choice and the directory. Select No Template.
ECE356 – Database Systems Lab 1 – Building a Web Project with NetBeans Tiuley Alguindigue Lab Instructor – University of Waterloo, E & CE Dept. Fall 2013.
Introduction to Liferay Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written.
Struts Portlet Database Interaction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without.
Basic Portlet Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
JSF Portlet Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Themes & Layout Tutorial Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written.
UNIT-V The MVC architecture and Struts Framework.
JSP and Servlets Lecture notes by Theodoros Anagnostopoulos.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
Pittsburgh Java User Group– Dec Java PureFaces: A JSF Framework Extension.
Ext Environment Copyright © 2005 Liferay, LLC All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Copyright © 2012 Accenture All Rights Reserved.Copyright © 2012 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are.
Struts Portlet Redirect Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
JDeveloper 10g and JavaServer Faces: High-Performance UIs on the Web Avrom Roy-Faderman Senior Programmer May, 2006.
JSP Java Server Pages Softsmith Infotech.
JavaServer Faces Jeff Schmitt October 5, Introduction to JSF Presents a standard framework for building presentation tiers for web applications.
Guidelines for Homework 6. Getting Started Homework 6 requires that you complete Homework 5. –All of HW5 must run on the GridFarm. –HW6 may run elsewhere.
1 Lecture 24 George Koutsogiannakis Spring 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
CSCI 6962: Server-side Design and Programming Introduction to Java Server Faces.
JBoss at Work JAW Motors Application Chapter 1-3 Jeff Schmitt October 9, 2006.
Java Server Pages A JSP page is a text-based document that contains two types of text: static template data, which can be expressed in any text-based format,
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
 Embeds Java code  In HTML tags  When used well  Simple way to generate dynamic web-pages  When misused (complex embedded Java)  Terribly messy.
Ext Environment Copyright © 2005 Liferay, LLC All Rights Reserved. No material may be reproduced electronically or in print without written permission.
J2EE Structure & Definitions Catie Welsh CSE 432
JSF Introduction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Basic Setup Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Java Web Development with NetBeans IDE -- Kai Qian Chapter 5 JavaServer Faces (JSF) Technology.
WaveMaker Visual AJAX Studio 4.0 Training Basics: Building Your First Application Binding Basics.
LDAP Authentication Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Topic Java EE installation (Eclipse, glassfish, etc.) Eclipse configuration for EE Creating a Java Web Dynamic Project Creating your first servlet.
Chapter 12 1 TOPIC 13B l Buttons and Action Listeners Window Interfaces Using Swing Objects.
JSF Framework Java Server Faces Presented by Songkran Totiya (6/10/2014)
Chính phủ điện tử TS. Phạm Văn Tính Khoa CNTT, ĐH Nông Lâm TP.HCM
 2007 Pearson Education, Inc. All rights reserved Ajax-Enabled JavaServer™ Faces Web Applications.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 41 JavaServer Face.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Bookstore Application: Middle Tier Introducing Code-Behind Files, Session State.
JSP Portlet Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Basic Portlet Copyright © 2000 – 2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Modern Programming Language. Web Container & Web Applications Web applications are server side applications The most essential requirement.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 5.1 Test-Driving the Enhanced Inventory Application.
JavaServer Faces framework Craig McClanahan is presented that created Struts web framework and based on experience gathered designed JavaServer.
Required Tools Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
12 Copyright © 2004, Oracle. All rights reserved. Using ADF Struts Components.
SDJ INFOSOFT PVT. LTD. 2 BROWSERBROWSER JSP JavaBean DB Req Res Application Layer Enterprise server/Data Sources.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
Struts 2 Development. Topics  Roles in Struts Development  Control Flow  Actions  Struts 2 Views and Target  Struts 2 Custom Tags  Validation 
Introduction to Java Server Faces (covered topics) ● Reasons to use „Java Server Faces“ ● JSF application structure ● JSF component model ● JSF managed.
Intro to JavaServer Faces Mimi Opkins CECS 493 Fall 2016.
Event Handling Mimi Opkins CECS 493 Fall 2016.
Copyright © Liferay, Inc.
Copyright © Liferay, Inc.
Unit 6-Chapter 2 Struts.
JSF Portlet Navigation and Event Listeners
Add Image and Title to Individual Page
JSF Portlet Message Bundles
Presentation transcript:

JSF Portlet Backing Beans and UI Components Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission from Liferay, Inc.

Objective 1.Add JSF UI Components –index.jsp 2.Register & create the Backing Bean with JSF –faces-config.xml 3.Bind Backing Bean Property to UI Component –index.jsp

Key Concepts UI Component –A Stateful object, maintained on the server, that provides functionality for interacting with an end user. –UI components are JavaBeans with properties, methods, and events. –Organized into a view, which is a tree of components usually displayed as a page. Backing Bean –Specialized JavaBeans that collect values from UI components and implement event listener methods.

Add JSF UI Components Modify …/ext/portlets/library_jsf.war/index.jsp and add some UI components.

index.jsp

Deploy the Files to Tomcat Open up a cmd prompt –Click “Start”, “Run” and then type “cmd” Navigate to your ext\portlets directory and then type “ant compile deploy” …\ext\portlets>ant compile deploy From your browser, Click Home A1 or use CTRL-F5 to reload the portlet

Register your Backing Bean with JSF Create …/ext/portlets/library_jsf_portlet.war/WEB- INF/faces-config.xml. This file is used to store all of your JSF configuration information:

faces-config.xml book com.ext.portlet.library.ui.BookBean request

Create your Backing Bean In …/ext/portlets/library_jsf_portlet.war/WEB- INF/src, use Eclipse to create com.ext.portlet.library.ui.BookBean:

BookBean.java package com.ext.portlet.library.ui; import java.util.ArrayList; import java.util.List; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.faces.event.ActionEvent; public class BookBean { public String getTitle() { return _title; } public void setTitle(String title) { _title = title; } private String _title; }

Initialize Values Modify faces-config.xml. This will initialize BookBean.title every time it is created (per request):

faces-config.xml book com.ext.portlet.library.ui.BookBean request title <book name>

Bind Backing Bean Property to UI Component Modify index.jsp. Adding value=“#{book.title}” binds the title property of the book bean to this input field.

index.jsp

Deploy the Files to Tomcat Open up a cmd prompt –Click “Start”, “Run” and then type “cmd” Navigate to your ext\portlets directory and then type “ant compile deploy” …\ext\portlets>ant compile deploy From your browser, Click Home A1 or use CTRL-F5 to reload the portlet

Create Command Button Modify index.jsp and add a command button. We will be using this button in a later exercise to add books to the database:

index.jsp

Register Simple Action Listener Modify index.jsp. Bind the BookBean.addBook() to the command button’s actionListener. When the form is submitted JSF will generate an action event that will invoke this actionListener:

index.jsp

Handle Action Event Modify BookBean.java. Add the addBook() to handle the action event generated by the commandButton. The event handler will clear the title field when it is invoked:

BookBean.java package com.ext.portlet.library.ui; import java.util.ArrayList; import java.util.List; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.faces.event.ActionEvent; public class BookBean { public String getTitle() { return _title; } public void setTitle(String title) { _title = title; } public void addBook(ActionEvent actionEvent) { // clear the title setTitle(""); } private String _title; }

Deploy the Files to Tomcat Compile and redeploy, restart Tomcat and refresh browser. Verify that the input field is being cleared after you submit the form.

Revision History James Min01/17/2007 Ivan Cheung01/30/2007