Comparative Display Technologies

30
Creative Commons Attribut ion- ShareAlike 2.5 License Sakai Programmer's Café Sakai Oxford Tetra ELF Workshop Comparative Display Technologies in Sakai Aaron Zeckoski [email protected]

description

 

Transcript of Comparative Display Technologies

Page 1: Comparative Display Technologies

Creative Commons Attribution-ShareAlike 2.5 License Sakai Programmer's Café

Sakai Oxford Tetra ELF Workshop

Comparative Display Technologies in Sakai

Aaron [email protected]

Page 2: Comparative Display Technologies

2

What do we want out of a display technology?

• Easy to use for the developer

• Good separation of Code and UI–i.e. easy to use for the UI designer

• Good integration with Sakai–Portal, widgets, tools, etc…

Page 3: Comparative Display Technologies

3

What technologies work

• Virtually any Java related display technology can work in Sakai

• There are some caveats– Sakai uses a special Servlet to handle redirects

and processing of HTTP request variables– Portal and widget interaction have to be developed

for each technology

• Bottom line: You are better off sticking with the ones that currently work

Page 4: Comparative Display Technologies

4

What games are there in town?

http://jakarta.apache.org/velocity/

http://java.sun.com/products/servlet/

http://java.sun.com/products/jsp/

JSF http://java.sun.com/javaee/javaserverfaces/

http://www2.caret.cam.ac.uk/rsfwiki/

But there are a few things to consider…

Page 5: Comparative Display Technologies

5

Java Servlets Intro

• modules of Java code that run in a server app to answer client requests

• HTML is hardcoded in the Java class– It can be pulled from external files though

• Most more advanced technologies are built on Servlets

• Sakai uses Servlet API 2.4

URL: http://en.wikipedia.org/wiki/Java_Servlet

Page 6: Comparative Display Technologies

6

Code Snippetpackage org.java.helloworld;

import java.io.*;import javax.servlet.*;import javax.servlet.http.*;

public class HelloWorld extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println("Hello World"); }}

URL: http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-First-Servlets.html

Page 7: Comparative Display Technologies

7

Java Servlets +

• Tried and tested technology (1997)

• Runs on the server instead of on the client like an applet

• Pure Java code

• Session tracking via HttpServlet

• Works fine in Sakai– Café Servlet Hello World sample code

Page 8: Comparative Display Technologies

8

Java Servlets -

• Invented in 1997 for goodness sake!

• HTML is placed in the Java class

• Impossible for UI designers to work with

• Poor separation of UI and Code

• Development this way is painful and slow compared to more modern methods

Page 9: Comparative Display Technologies

9

Java Servlets Final

• Why would you want to write pure Servlets any more considering the many better options out there?

• You are going to use Servlets anyway but at least use something along with it

• Bottom line: Don’t use this unless you just want to put an existing Servlet app into Sakai

Page 10: Comparative Display Technologies

10

Velocity Templates Intro

• Java based template engine

• Uses “references” to place dynamic content in html pages with # or $ vars– Somewhat similar to PHP or JSP

• Meant to allow UI designers to work alongside programmers

• Apache project

URL: http://jakarta.apache.org/velocity/

Page 11: Comparative Display Technologies

11

Code Snippet<HTML>

<HEAD><title>Velocity Sample</title></HEAD><BODY><h1>Hello $user.name</h1><table>

#foreach( $item in $items )#if ( $itemCheck($item) )<tr>

<td> $item.value </td></tr>#end

#end </table></BODY></HTML>

Page 12: Comparative Display Technologies

12

Velocity Templates +

• Uses “references” to place dynamic content in html template pages– Somewhat similar to PHP or JSP

• Most used display technology in Sakai– Integration with Sakai is good

• Ok separation of UI and Code

• Decent docs and community

Page 13: Comparative Display Technologies

13

Velocity Templates -

• The current Velocity implementation in Sakai is a custom and out of date version

• Integration with Sakai is OK but not really being worked on much anymore

• New development in Velocity is discouraged by the community

• Mostly carried over from CHEF

Page 14: Comparative Display Technologies

14

Velocity Templates Final

• Go for technologies that provide better separation between Code and UI

• Bottom line: You are better off not using this, only use this if you have existing apps and cannot rewrite them

Page 15: Comparative Display Technologies

15

Java Server Pages Intro

• Dynamic Java web content scripting language– Very similar to PHP

• JSP pages are compiled into Servlets when accessed

• Pages are a mixture of HTML, taglib tags, and Code

URL: http://java.sun.com/products/jsp/

Page 16: Comparative Display Technologies

16

Code Snippet<HTML>

<HEAD><title>JSP Sample</title></HEAD><BODY><h1>Hello <%= user.getName() %></h1>Today is <%= new Date() %><br/><ul><% for (int i=0; i<items.size(); i++) { %>

<li><%= ((Item)items.get(i)).getValue() %></li><% } %></ul></BODY></HTML>

Page 17: Comparative Display Technologies

17

Java Server Pages +

• Easy to develop in and work with• Can be changed without restarting• Works fairly well in Sakai

– JSP support is available via a cool Servlet by Andrew Thornton (Cambridge)

– Used in Rwiki (sorta), XML version

• Well tested technology with large community

• Excellent docs and many books

Page 18: Comparative Display Technologies

18

Java Server Pages -

• Mixes code and HTML together– Poor separation of code and UI design

• Compiled when accessed– This can cause a noticeable delay when

accessing a page for the first time

• Integration with Sakai is poor• Has many of the same weaknesses that

other scripting languages have

Page 19: Comparative Display Technologies

19

Java Server Pages Final

• JSP support in Sakai is not great yet

• It is difficult for UI designers

• Bottom line: Use this if you have existing JSP code, but go for options that provider better separation between UI and Code for new projects

Page 20: Comparative Display Technologies

20

Java Server Faces Intro• A Java based set of APIs for managing

state, handling events, and defining navigation

• Mostly builds on JSP– Though it can be used without JSPs

• Includes a custom set of tag libraries• Includes error handling, input validation,

and internationalization support

JSF

URL: http://java.sun.com/javaee/javaserverfaces/

Page 21: Comparative Display Technologies

21

Code Snippet<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %><%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %><html><head><title>JSF sample</title></head><body> <f:view> <h1><h:outputText value=“Hello #{user.name}"/></h1> <h:dataTable id=“items" value="#{itemsBean.items}" var=“item"> <h:column> <h:outputText value="#{item.value}" /> </h:column> </h:dataTable> </f:view></body></html>

JSF

Page 22: Comparative Display Technologies

22

Java Server Faces +• The second most used display

technology in Sakai (after Velocity)– Used for the portal and a small number of

apps (Gradebook, Assignments, etc…)

• Integrates well with Sakai– better than any of the other current solutions

(for now)

• MyFaces and Oracle ADF Faces• Pretty good docs and books

JSF

Page 23: Comparative Display Technologies

23

Java Server Faces -• Pretty heavyweight and has problems in

the current version– These might be fixed in the upcoming

version• Poor separation of UI design and code• High learning curve• Difficult to use and not very flexible• Poor AJAX/Javascript integration• Does not work with browser navigation

JSF

Page 24: Comparative Display Technologies

24

Java Server Faces Final• Most new apps in Sakai are written in

this but it is recognized as having many weaknesses

• High learning curve and difficulty of use means slow development

• Bottom line: Don’t use this unless you really have to, even if you have existing code

JSF

Page 25: Comparative Display Technologies

25

Reasonable Server Faces

• Spring based web programming framework

• Uses pure XHTML templates, clean separation of UI and Code

• Lightweight and pure bean programming

• Works well with AJAX and Javascript

URL: http://jakarta.apache.org/velocity/

Page 26: Comparative Display Technologies

26

Code Snippet<html><head><title>RSF sample</title></head><body>

<h1>Hello <span rsf:id=“user-name”>User Name</span></h1>Today is <span rsf:id=“current-date”>1/1/2006</span><br/><table> <tr rsf:id=“items:”> <td rsf:id=“item-value”>item value here</td> </tr></table>

</body></html>

Page 27: Comparative Display Technologies

27

Reasonable Server Faces +• Uses pure XHTML templates

– Provides clean separation of UI and Code

• Respects the HTTP request cycle– Back button works!

• Works well with AJAX and Javascript

• Sakai integration and features are improving rapidly

• Good docs and code samples available on the RSF Wiki

Page 28: Comparative Display Technologies

28

Reasonable Server Faces -

• Greater separation of UI and code can require more files and lines of code– This is true of other solutions as well

• Not used in Sakai core yet but is fully functional in it and integrates somewhat– Some code in Sakai Contrib (rsf gallery)

• Small user community• Still in development (also a positive)

Page 29: Comparative Display Technologies

29

Reasonable Server Faces Final

• The only really good separation of UI design and Code available

• Community support is growing and Sakai integration improving

• Bottom line: Use of this is recommended for new Sakai apps

Page 30: Comparative Display Technologies

30

Summary

JSF

• No plain Servlets

• Velocity discouraged

• JSP ok for small stuff

• JSF is just bad

• RSF recommended