JSF AJAX Netbeans

2y ago
119 Views
4 Downloads
745.65 KB
22 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Kamden Hassan
Transcription

JSF and AJAX withNetbeans 5.5Wanasanan Thongsongkrit(NAS) :)

AJAX2

AJAX’s shortcomingBecause AJAX is new, it has very inconsistentsupport among browsers. Also, to develop with AJAX, you need to havesome knowledge of JavaScript, which is out ofreach for many page authors. 3

Learning AJAX Fast (easy) if you are a JavaScript guruhave memorized the entireDOM APIown and study books onDHTML, JavaScript, CSS,AJAX and useful hacks foreach technology Slow (hard) if you come from a mostly staticHTML/CSS backgroundare comfortable withtraditional web applicationarchitectures built aroundan HTTP POSTprimary use of JavaScriptis cut-and-paste of cuteanimations and other coolin-page behaviors4

AJAX toolkits The complete list indicates some 160 toolkits existKeith provided a pointer to a popularity survey of AJAXtoolkits (as of September 23, 2006) Prototype (48%)Script.aculo.us (33%)Dojo (19%)DWR (12%)Moo.fx (11%)jQuery (7%)Rico (5%)Yahoo UI (5%)Atlas (4%)MochiKit (4%)XAjAX (4%)GWT (3%)5

How to avoid learning javascriptand all toolkits? Use components that encapsulate AJAX insideBenefits Hide functionality behind simple building blocksPage author do not have to write all java scripts themselves butlet the component do the complicated workPage authors have an easier time maintaining their pagesReusable componentsTechnology used: Java Server Faces (JSF) author can just drag and drop the components onto a page usinga tool such as Sun Java Studio Creator or the NetBeans IDE.6

Create Great-Looking GUIs WithNetBeans IDE 5.57

NetBeans Enterprise Pack(Beta version)8

jMaki Framework (plug-in) JavaScript Wrapper framework for the Java platformwraps popular AJAX frameworks into a JSP or JSF tagProvides a common programming model to developersFamiliar to Java EE application developersLeverages the widgets from popular frameworks (See)DojoMochikit FlickrSpryGoogleYahooScriptaculusDHTMLWhat you need is: jMaki 115/41646/org-netbeans-modules-sun-jmaki.nbm9

Basic jMakiApplicationStructurejmaki.js the JavaScriptbootstrapper and utilities thatmanages the loading of jMaki widgetson the client, makes XMLHttpRequests, loads additional resources, provides inter-widgetcommunication using publishand subscribe stores widget instances to beshared across an application. a:ajax name "jmaki.delicious"/ config.json configuration of3rd party libraries used by jMaki10

jMaki: made up of JavaScript Runtime, the Server SideRuntime, and the XmlHttpProxy.11

JavaScript Runtime (jmaki.js) responsible for bootstrapping all widgets and passing parameters provided by aserver-side runtime.makes sure that each widget instance gets the correct parametersthat were passed from the server-side runtime.uses default parameters (if not provided) that may then becustomized for each widget.provides convenient APIs for performing an XMLHttpRequestand loading resources based on JSON with Padding (JSONP).provides APIs for a widget to load extra scripts, styles, andresources needed by a widget.provides a publish subscribe mechanism for widget-basedcommunication.provides a common namespace to store and access widgetsThe key point of the API is that you can program toone API and access widgets from any given toolkit.12

Server-Side Runtime responsible for applying changes and rendering HTML templates.renders all script and CSS references based on whichtype is centrally configured.responsible for serializing parameters (specified asattributes in a JSP or JSF tag) that are passed to theJavaScript runtime.capable of mapping widget values back into serverbased model data, such as managed objects, webservices, or databases.13

XmlHttpProxy provides a generic JSON-based access to awidget range of XML-based services using anHTTP client. services include RSS feeds, Yahoo services such asgeocoding, Flickr image searches, and many more tocome.allows widgets to access services in a uniformway by providing XSL-to-JSON transformationsthat can be easily customized.14

How author configurewidgets’ parameters via jMaki? using JSONjMaki WidgetJSON(parameters)wrappedWidget15

Using Your Own Data With ajMaki Widget to add your own data to a widget (JSON format): Using a static fileUsing a JavaServer Faces managed beanUsing a JSP page or a servlet16

Demo: Publish and SubscribeMechanism with Yahoo Geocoder a:ajax name "yahoo.geocoder" service "/xhp"/ widget script type "text/javascript" Subscribefunction geoCoderListener(coordinates) {var targetDiv document.getElementById("geocoder001 message");var reponseText "";for (var i in coordinates) {reponseText "Latitude " coordinates[i].latitude " Longitude " coordinates[i].longitude " br ";}targetDiv.innerHTML reponseText;}// subscribe to the topic '/yahoo/geocode' to which this widget publishes eventsjmaki.subscribe("/yahoo/geocoder", geoCoderListener); /script div id "geocoder001 message" /div Display location17

Geocoder’sComponent.html (hidden) div id " {uuid}" formonsubmit "jmaki.attributes.get(' {uuid}').getCoordinates();return false;" Location: input type "text" id " {uuid} location" input type "button" value "Get Coordinates"onclick "jmaki.attributes.get(' {uuid}').getCoordinates();" /form /div 18

Geocoder’sComponent.js (hidden)if (typeof jmaki.GeoCoder 'undefined'){jmaki.GeoCoder function( widget) {var topic "/yahoo/geocoder";var uuid widget.uuid;var service widget.service;if (typeof widget.args ! 'undefined' &&typeof widget.args.topic ! 'undefined') {topic widget.args.topic;uses defaultparameters}19

Geocoder’sComponent.js (hidden)var location;this.getCoordinates function() {Wrapped functionlocation encodeURIComponent(document.getElementById(uuid " location").value);var encodedLocation encodeURIComponent("location " location);var url service "?key yahoogeocoder&urlparams " encodedLocation;jmaki.doAjax({url: url, callback: function(req) { var req req;postProcess( req);}});}20

Componet.js (hidden)function postProcess(req) {if (req.readyState 4) {if (req.status 200) {var response eval("(" req.responseText ")");jmaki.publish(topic, response.coordinates);}}Publish}response}}var geocoder new jmaki.GeoCoder(widget);// add to the instance map for later refernecejmaki.attributes.put(widget.uuid, geocoder);21

Referenceshttps://ajax.dev.java.net/ https://ajax.dev.java.net/download.html http://javaserver.org/jmaki/ http://www.netbeans.org/ torial.jsp tro/ http://www.google.com/apis/maps/ 22

Technology used: Java Server Faces (JSF) author can just drag and drop the components onto a page using a

Related Documents:

4 NetBeans 6.1 Started as students project in 1996 (Xelfi) Supported Swing in 1999 Sun acquires both Forté and NetBeans in 1999 NetBeans renamed to Forté for Java in 1999 NetBeans becomes Open Source again in 2000 NetBeans 4.0 introduces projects system NetBeans 4.1 introduces full J2EE support NetBeans 5.0 introduces Matisse NetBeans 5.5 introduces Enterprise Pack

Using C with NetBeans For Introduction to Programming With C NOTE: This tutorial is for experience users to develop C programs using NetBeans. To use C with NetBeans, you have to download and install a C compiler and NetBeans. Installing a C Compiler NetBeans can work with any C compiler. In this tutorial, we will

JSF has nothing to do with JSP per se. JSF works with JSP through a JSP tag library bridge. However, the life cycle of JSF is very different from the life cycle of JSP. Facelets fits JSF much better than JSP because Facelets was designed with JSF in mind, whereas integrating JSF and JSP has

Assume that you have successfully installed NetBeans on your machine. Start NetBeans from Windows, Linux, or Solaris. The NetBeans main window appears, as shown in Figure 1. Figure 1 The NetBeans main window is the command center for the IDE. The NetBeans main window contains menus, toolbars, project

The NetBeans IDE is written in Java and can run on Windows, OS X, Linux, Solaris and other platforms supporting a compatible JVM. The NetBeans Platform allows applications to be developed from a set of modularsoftwarecomponents called modules . Applications based on the NetBeans Platform (including the NetBeans IDE itself) can be extended by third

JSF includes a set of predefined UI components, an event-driven programming model, and the ability to add third-party components. JSF is designed to be extensible, easy to use, and toolable. This refcard describes the JSF development process, standard JSF tags, the JSF expressi

Building JavaServer Faces Applications 7 JSF – A Web Framework JSR 127 – JSF specification v1.1 JSF 1.2 in progress (JSR 252) JSP 2.1 (JSR 245) will align with JSF JSF spec lead was the Struts architect JavaServer Faces technology simplifies building user interfaces for JavaServer

NetBeans Developing Applications with NetBeans IDE Release 7.4 E40142-08 November 2013 Documentation for NetBeans users that describes how to use