Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Introduction to Reasonable Server Faces Aaron Zeckoski

Slides:



Advertisements
Similar presentations
Web Development with Karsten Schulz Terp-Nielsen Master Principal Sales Consultant Oracle Denmark.
Advertisements

Apache Struts Technology
INTRODUCTION TO ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Introduction to Java Server Faces Aaron Zeckoski
Sakai Programmer's Café Introduction to RSF — II. EL, Scopes and the Request Cycle Antranig Basman
Internet Technologies 1 Master of Information System Management Java Server Faces Model/View/Controller Design Pattern for Web Development Slides.
Forms Review. 2 Using Forms tag  Contains the form elements on a web page  Container tag tag  Configures a variety of form elements including text.
DT211/3 Internet Application Development
Java Server Faces Model/View/Controller Design Pattern for Web Development Slides adapted from “Core JavaServer Faces” by Geary and Horstmann and the J2EE.
Apache Struts Technology A MVC Framework for Java Web Applications.
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
UNIT-V The MVC architecture and Struts Framework.
Reasonable Sakai Widgets Aaron Zeckoski Gonzalo Silverio Antranig Basman
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License RSF Wiki Introduction to Reasonable Server Faces Aaron Zeckoski and Antranig Basman.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
11. Java-Based Web: JSP, JSF. 2 Motto: Rule 1: Our client is always right Rule 2: If you think our client is wrong, see Rule 1. - Anonymous.
Java Server Pages CS-422. What are JSPs A logical evolution of java servlets –most servlets dynamically create HTML and integrate it with some computational.
Pittsburgh Java User Group– Dec Java PureFaces: A JSF Framework Extension.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Saki PSaki PUK Introducing RSF (Reasonable Server Faces) Aaron.
Server-side Scripting Powering the webs favourite services.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Saki PSaki PUK New and Upcoming RSF Features – Antranig.
JDeveloper 10g and JavaServer Faces: High-Performance UIs on the Web Avrom Roy-Faderman Senior Programmer May, 2006.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Saki PSaki PUK Idiomatic RSF – OTP, Messaging and BeanGuards.
JavaServer Faces Jeff Schmitt October 5, Introduction to JSF Presents a standard framework for building presentation tiers for web applications.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmers’ Café Sakai NWU Workshop, South Africa Spring Fundamentals & RSF Fundamentals.
Introduction to JavaServer Pages (JSP) Slides from Dr. Mark Llewellyn.
CSCI 6962: Server-side Design and Programming Introduction to Java Server Faces.
Standalone Java Application vs. Java Web Application
JSF Introduction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License RSF Wiki Introduction to Reasonable Server Faces Aaron Zeckoski
Fall CIS 764 Database Systems Design L8. Web ….
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Introduction to Spring Framework,
Chapter 6 Server-side Programming: Java Servlets
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License RSF Wiki Introduction to Reasonable Server Faces Aaron Zeckoski
JSF Framework Java Server Faces Presented by Songkran Totiya (6/10/2014)
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
.  A multi layer architecture powered by Spring Framework, ExtJS, Spring Security and Hibernate.  Taken advantage of Spring’s multi layer injection.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai development and app/tool tips Aaron Zeckoski
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Chính phủ điện tử TS. Phạm Văn Tính Khoa CNTT, ĐH Nông Lâm TP.HCM
Apache Struts. J2EE Web Application using MVC design pattern Why MVC? Separate components = easier maintenance – Model component holds object data – View.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Sakai code exercises Aaron Zeckoski.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
Chapter 12© copyright Janson Industries Java Server Faces ▮ Explain the JSF framework ▮ SDO (service data objects) ▮ Facelets ▮ Pagecode classes.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
Idiomatic RSF – OTP and BeanGuards Antranig Basman, CARET, University of Cambridge.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Chapter 2 Java Struct 2. Content Basic MVC Architecture Struts 2 Overview Struts 2 - Architecture.
By Jonathan Smith. Road Map Introduction Company Information Project Overview Java Web Design and Development Summary Relation to IUP Acknowledgments.
Apache Struts Technology A MVC Framework for Java Web Applications.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Introduction to Spring Framework.
HTML III (Forms) Robin Burke ECT 270. Outline Where we are in this class Web applications HTML Forms Break Forms lab.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Comparative Display Technologies.
Creative Commons Attribution- ShareAlike 2.5 License Sakai Programmer's Café Sakai Oxford Tetra ELF Workshop Comparative Display Technologies in Sakai.
Chapter 1 Getting Started with ASP.NET Objectives Why ASP? To get familiar with our IDE (Integrated Development Environment ), Visual Studio. Understand.
Section 10.1 Define scripting
Sakai WebApp Structure
JavaServer Faces: The Fundamentals
Presentation transcript:

Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Introduction to Reasonable Server Faces Aaron Zeckoski

2 Reasonable Server Faces RSF is a Java web programming framework –Roughly the same scope as Sun’s JSF –Includes the following Navigation and View rendering Server-side and client-side state management Request cycle handling and abstraction APIs for UI components and view producers Pure HTML templating Lightweight Expression Language (EL) Based on the Spring Framework

3 Theory vs. Practice

4 In theory Web applications that are as easy to create as PHP but still well structured –Easier to program –Standard HTTP request cycle, zero server state Better scoping and separation –Application/Session/Request Component bindings from UI to model True separation of the logic and presentation –Wireframe is the view definition (easy design) Easy to configure for different environments

5 In practice Harder to work with than PHP but easier than most Java based frameworks –Basic understanding of the request cycle needed Especially if using Session beans –No in-code dependence on Servlets Can use all of the capability of HTML –Truly pure HTML templating (excellent for designers) –Complete separation of UI and logic Knowledge of Spring important –Does provide flexibility and configurability via Spring –Full support for IoC and AOP for backing beans and producers –Adds support for request scope IoC No globally visible state maintainers (stateless)

6 RSF structure and code

7 RSF structure The template (always html) defines the interface The producer (java or xml) defines the view, populates the template, and handles navigation ViewParams define the values passed between views (get) The requestContext defines producer and backing beans The applicationContext defines app scope beans and handles rsf app config (via spring) Backing beans handle action processing Logic layer beans can be injected as defined in the context xml files Model is basic data POJO Template (html) Backing Bean (java) Logic Layer (rest of app) requestContext (xml) model (java) Producer (java) applicationContext (xml) ViewParams (java)

8 RSF templates XHTML files –Must be valid XML or runtime error will occur No custom tags used or needed –Truly is a pure XHTML template Only uses one custom attribute –rsf:id - identifies this component for the producer Template (html)

9 Sample template RSF Items Hello, Current User Non updateable item New item title Sep 15, :26 AM

10 RSF producer Controls displays logic and populates the template with dynamic information Defines a view uniquely –By setting a ViewID Recommend you create a public static VIEW_ID Implements ViewComponentProducer –Define start page by implementing DefaultView –Implement NavigationCaseReporter to control “submit” navigation –Implement ViewParamsReporter to receive query parameters from http request Producer (java)

11 Sample producer public class ItemsProducer implements ViewComponentProducer, DefaultView { public static final String VIEW_ID = "Items"; public String getViewID() { return VIEW_ID; } private CrudPlusLogic logic; public void setLogic(CrudPlusLogic logic) { this.logic = logic; } public void fillComponents(UIContainer tofill, ViewParameters viewparams, ComponentChecker checker) { UIOutput.make(tofill, "current-user-name", logic.getCurrentUserDisplayName()); UIForm listform = UIForm.make(tofill, "listItemsForm"); List l = logic.getAllVisibleItems(); for (Iterator iter = l.iterator(); iter.hasNext();) { CrudPlusItem item = (CrudPlusItem) iter.next(); UIBranchContainer itemrow = UIBranchContainer.make(listform, "item-row:", item.getId().toString() ); if (logic.canWriteItem(item)) { UIInternalLink.make(itemrow, "item-update", item.getTitle(), new AddItemViewParameters(AddItemProducer.VIEW_ID, item.getId()) ); } else { UIOutput.make(itemrow, "item-title", item.getTitle() ); } UIOutput.make(itemrow, "item-dateCreated", item.getDateCreated() ); }

12 RSF ViewParams Controls the passing of data between page views –Uses query parameters (GET) –extends SimpleViewParameters Should be used when data needs to be sent from one view to another –Works like standard web variables should –Can be reused on multiple pages ViewParams (java)

13 Sample ViewParams public class AddItemViewParameters extends SimpleViewParameters { public Long id; // an identifier for an item public AddItemViewParameters() { } public AddItemViewParameters(String viewID, Long id) { this.id = id; this.viewID = viewID; } public String getParseSpec() { // include a comma delimited list of the // public properties in this class return super.getParseSpec() + ",id"; }

14 RSF requestContext Request Scope Context –Often called RSACRSAC All RSAC beans are lazy by default Standard spring bean definition file –Uses the Spring file parser code –Only includes a subset of the standard functionality to increase speedincludes a subset Location of this file is set in the web.xml requestContext (xml)

15 Sample requestContext <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" " <bean id="itemsBean" class="org.sakaiproject.crudplus.tool.ItemsBean" init-method="init"> <property name="logic" ref="org.sakaiproject.crudplus.logic.CrudPlusLogic" /> <property name="logic" ref="org.sakaiproject.crudplus.logic.CrudPlusLogic" /> <property name="logic" ref="org.sakaiproject.crudplus.logic.CrudPlusLogic" />

16 RSF applicationContext A standard Spring bean definition file –Puts the beans in the application context Mostly used for configuring RSF –Define child of requestAddressibleParent to specify beans which can be the target of EL –Define child of beanScopeParent to create a new session scope for session beans –Define a child of CRITemplateResolverStrategy to control the location of templates Location of this file set in web.xml applicationContext (xml)

17 Sample applicationContext <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" " <!-- For security purposes, only beans listed in the comma separated value list may be the target of EL operations coming in over the request -->

18 RSF Backing Bean Typical bean with methods to handle actions and public properties –No RSF dependencies –Store data needed for processing the user actions using public properties –Control data model objects with public properties (using EL from producer) –Process actions using methods Can interact with logic layer –But so can the producers Created and destroyed in the request cycle by default (recommended practice) –Can override this behavior Backing Bean (java)

19 Sample backing bean public class ItemsBean { public CrudPlusItem newItem = new CrudPlusItem(); public Map selectedIds = new HashMap();... private CrudPlusLogic logic; public void setLogic(CrudPlusLogic logic) { this.logic = logic; }... public String processActionAdd() { if (newItem.getHidden() == null) { // null here means that the box was not checked newItem.setHidden( DEFAULT_HIDDEN ); } logic.saveItem(newItem); return "added"; }

20 Web app basics 4 key things you need to do in a webapp 1.Output dynamic text Render data to the screen 2.Loop structures Output collection or render tables 3.Optional rendering of components Render some components based on state 4.Trigger Actions User actions or data transmission In RSF, these all are done using one part in the template and another in the producer (and maybe the backing bean for an action method)

21 Output dynamic text Hello, Current User Uses an rsf:id on an HTML entity to show where to place the dynamic text –Does not have to be a span or div only! UIOutput will send the escaped string to the id location in the component tree –Non-escaped output using UIVerbatim Not recommended though UIOutput.make(tofill, "current-user-name", logic.getCurrentUserDisplayName()); 1

22 Loop structure List l = logic.getAllVisibleItems(); for (Iterator iter = l.iterator(); iter.hasNext();) { Item item = (Item) iter.next(); UIBranchContainer itemrow = UIBranchContainer.make(listform, "item-row:", item.getId().toString() ); if (logic.canWriteItem(item)) { UIInternalLink.make(itemrow, "item-update", item.getTitle(), new AddItemViewParameters(AddItemProducer.VIEW_ID, item.getId()) ); } else { UIOutput.make(itemrow, "item-title", item.getTitle() ); } UIOutput.make(itemrow, "item-dateCreated", item.getDateCreated() ); } Non updateable item New item title Sep 15, :26 AM 2

23 Optional rendering HTML entities are rendered if the component is tied via the rsf:id –If there is no UI component for the id then the render skips over it Can do this for single entities or for UIBranchContainers to do a block –Example: a surrounding if (item.getHidden().booleanValue()) { UIOutput.make(itemrow, "item-title", item.getTitle() ); } Hidden item title 3

24 Trigger actions Use a normal submit button with an id –Use UICommand to tie to an action method in a backing bean using EL Return string ties to a navigation case in the producer <input rsf:id="add-update-item" type="submit" value="Add/Update Item" /> UICommand.make(addupdateitem, "add-update-item", "#{itemsBean.processActionAdd}"); public String processActionAdd() { logic.saveItem(updateItem); return "added"; } 4

25 RSF in practice

26 RSF experience RSF has a moderate learning curve –Mostly unlearning poor practices UI components are comprehensive –Cover all HTML entities, fairly flexible AJAX integration easy –Designed to work well with AJAX and JS Works like a webapp should –Normal REST, back button works Easy for UI designers to work with

27 RSF EL A subset of the functionality of JSF Expression Language –No logic in the expression –Sometimes called Value Language (VL) Works with any bean in the request or application context More info on the RSF EL pageRSF EL page #{requestwriteablebean.property1.subproperty2} URL:

28 RSF component trees Binds the markup to the model –rsf:id in the template –EL in the producer Tree and components created and destroyed during the request cycle –Short lived, frees up resources –Rooted in a view and only kept around long enough to render the view URL:

29 RSF structure revisit The template is pure html –Easy for UI designers The producer is simple and cleanly defines a view ViewParams abstract out the passing of values The requestContext and applicationContext are pure spring config –Can be mixed up sometimes Backing beans are really just simple beans Template (html) Backing Bean (java) Logic Layer (rest of app) requestContext (xml) model (java) Producer (java) applicationContext (xml) ViewParams (java)

30 RSF resources RSF Wiki (online documentation) – RSF forums – RSF APIs – RSF SVN –

31 Questions? RSF –