Monday, April 21, 2014

[Java] JSF - Java Server Faces

TOPIC 
  • JSF concept
  • MVC architecture
  • Navigation Rules
  • XML configuration file 
  • What is backing bean?
  • Life cycle
  • How to do rendering?


What is JSF?

  • JSF stands for Java Server Faces
  • JSF is user interface (UI) framework for Java web applications. By this it means complex components are pre-coded and can be used with ease. 
  • It is event-driven programming model. By that it means that JSF has all necessary code for event handling and component organization. 
  • Application programmers can concentrate on application logic rather sending effort on these issues. 
  • It has component model that enables third-party components to be added like AJAX.



What is required for JSF to get started?


Following things required for JSF:
  • JDK (Java SE Development Kit)
  • JSF 1.2
  • Application Server (Tomcat or any standard application server)
  • Integrated Development Environment (IDE) Ex. Netbeans 5.5, Eclipse 3.2.x, etc.
Once JDK and Application Server is downloaded and configured, one can copy the JSF jar files to JSF project and could just start coding. :-)
If IDE is used, it will make things very smooth and will save your time.




JSF Architecture

JSF was developed using MVC (a.k.a Model View Controller) design pattern so that applications can be scaled better with greater maintainability.
It is driven by Java Community Process (JCP) and has become a standard.

The advantage of JSF is that it has both a Java Web user and interface and a framework that fits well with the MVC.
It provides clean separation between presentation and behavior.
UI (a.k.a User Interface) can be created by page author using reusable UI components and business logic part can be implemented using managed beans.


How the components of JSF are rendered? An Example

In an application add the JSF libraries. Further in the .jsp page one has to add the tag library like:

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> 

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>

Or one can try XML style as well:

<?xml version="1.0"?> 
<jsp:root version="2.0" 
xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:f="http://java.sun.com/jsf/core" 
xmlns:h="http://java.sun.com/jsf/html">

Once this is done, one can access the JSF components using the prefix attached. If working with an IDE (a.k.a Integrated Development Environment) one can easily add JSF but when working without them one also has to update/make the faces-config.xml and have to populate the file with classes i.e. Managed Beans between

<faces-config> </faces-config> tags




How to declare the Navigation Rules for JSF?

Navigation rules tells JSF implementation which page to send back to the browser after a form has been submitted. For ex. for a login page, after the login gets successful, it should go to Main page, else to return on the same login page, for that we have to code as:

<navigation-rule>
     <from-view-id>/login.jsp</from-view-id>
     <navigation-case>
          <from-outcome>login</from-outcome>
          <to-view-id>/main.jsp<to-view-id>
     </navigation-case>
 

      <navigation-case>
          <from-outcome>fail</from-outcome>
          <to-view-id>/login.jsp<to-view-id>
     </navigation-case>
</navigation-rule>


from-outcome to be match with action attribute of the command button of the login.jsp as:

<h:commandbutton value="Login" action="login"/>
Secondly, it should also match with the navigation rule in face-config.xml as

face-config.xml
 <managed-bean>
    <managed-bean-name>user</managed-bean-name>
    <managed-bean-class>core.jsf.LoginBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
</managed-bean> 

In the UI component, to be declared / used as:


<h:inputText value="#{user.name}"/>
value attribute refers to name property of the user bean.



How do I configure the configuration file?

The configuration file used is our old web.xml, if we use some IDE it will be pretty simple to generate but the contents will be something like below:


<?xml version="e;1.0"e; encoding="e;UTF-8"e;?>
<web-app version="e;2.4"e; xmlns="e;http://java.sun.com/xml/ns/j2ee"e;
xmlns:xsi="e;http://www.w3.org/2001/XMLSchema-instance"e;
xsi:schemaLocation="e;http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"e;>
 

 <context-param> 
    <param-name>com.sun.faces.verifyObjects</param-name>
    <param-value>false</param-value>
</context-param>

<context-param>
     
    <param-name>com.sun.faces.validateXml</param-name>      
    <param-value>true</param-value>
</context-param>

<context-param>
    
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>      
    <param-value>client</param-value>
</context-param>


<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>     <load-on-startup>1</load-on-startup>
</servlet>


<servlet-mapping>
    
    <servlet-name>Faces Servlet</servlet-name>      
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>


<session-config>
     
    <session-timeout> 30 </session-timeout>
</session-config>


<welcome-file-list>
     
    <welcome-file> index.jsp </welcome-file>
</welcome-file-list>
</web-app>


The unique thing about this file is ?servlet mapping?. JSF pages are processed by a servlet known to be part of JSF implementation code. In the example above, it has extension of .faces. It would be wrong to point your browser to http://localhost:8080/MyJSF/login.jsp, but it has to be http://localhost:8080/MyJSF/login.faces. If you want that your pages to be with .jsf, it can be done with small modification :-),

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>     <url-pattern>*.jsf</url-pattern>
<servlet-mapping>



How does JSF depict the MVC (Model View Controller) model? 

The data that is manipulated in form or the other is done by model. The data presented to user in one form or the other is done by view. JSF is connects the view and the model. View can be depicted as shown by:


<h:inputText value="#{user.name}"/>
JSF acts as controller by way of action processing done by the user or triggering of an event. For ex.

<h:commandbutton value="Login" action="login"/>
this button event will triggered by the user on Button press, which will invoke the login Bean as stated in the faces-config.xml file.

Hence, it could be summarized as below: User Button Click -> form submission to server ->; invocation (救助) of Bean class ->; result thrown by Bean class caught be navigation rule ->; navigation rule based on action directs to specific page.



How to get current page URL from backing bean?

You can get a reference to the HTTP request object via FacesContext like this:

FacesContext fc = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) fc.getExternalContext().getRequest();


and then use the normal request methods to obtain path information. Alternatively,

context.getViewRoot().getViewId();
will return you the name of the current JSP (JSF view IDs are basically just JSP path names).



Discuss life cycle in JSF.

The life cycle of a JavaServer Faces page is similar to that of a JSP page: The client makes an HTTP request for the page, and the server responds with the page translated to HTML. However, because of the extra features that JavaServer Faces technology offers, the life cycle provides some additional services to process a page.

JSF application lifecycle consists of six phases which are as follows
  • Restore view phase 
  • Apply request values phase; process events 
  • Process validations phase; process events 
  • Update model values phase; process events 
  • Invoke application phase; process events 
  • Render response phase 

Restore View Phase: 
When a request for a JavaServer Faces page is made, such as when a link or a button is clicked, the JavaServer Faces implementation begins the restore view phase.

Apply Request Values Phase: 
After the component tree is restored, each component in the tree extracts its new value from the request parameters by using its decode method. The value is then stored locally on the component. If the conversion of the value fails, an error message associated with the component is generated and queued on FacesContext. This message will be displayed during the render response phase, along with any validation errors resulting from the process validations phase. '

Process Validations Phase: 
During this phase, the JavaServer Faces implementation processes all validators registered on the components in the tree. It examines the component attributes that specify the rules for the validation and compares these rules to the local value stored for the component.

Update Model Values Phase: 
After the JavaServer Faces implementation determines that the data is valid, it can walk the component tree and set the corresponding server-side object properties to the components' local values. The JavaServer Faces implementation will update only the bean properties pointed at by an input component's value attribute. If the local data cannot be converted to the types specified by the bean properties, the life cycle advances directly to the render response phase so that the page is rerendered with errors displayed. This is similar to what happens with validation errors.

Invoke Application Phase: 
During this phase, the JavaServer Faces implementation handles any application-level events, such as submitting a form or linking to another page.

Render Response Phase: 
During this phase, the JavaServer Faces implementation delegates authority for rendering the page to the JSP container if the application is using JSP pages. If this is an initial request, the components represented on the page will be added to the component tree as the JSP container executes the page. If this is not an initial request, the components are already added to the tree so they needn't be added again. In either case, the components will render themselves as the JSP container traverses the tags in the page.

JSF與Struts雖然都是Web MVC架構的實現,但兩者所偏重的並不相同,Struts著重的是控制物件的設計;JSF則著重於頁面流程的設計,也就是定義在何種條件成立下,上一個頁 面與下一個頁面之間是如何連結,您可以在faces-config.xml中定義頁面流程



Source:
http://www.withoutbook.com/Technology.php?tech=37&page=5&subject=JSF%20Interview%20Questions%20and%20Answers

http://openhome.cc/Gossip/SpringGossip/FirstJSF.html

[Web Technology] Web Service

"网络服务"(Web Service)的本质,就是通过网络调用其他网站的资源
举例来说,去年我写过一个"四川大地震图片墙",它能动态显示关于四川地震的最新图片。但是,所有的图片都不是储存在我的服务器上,而是来自flickr.com。我只是发出一个动态请求,要求flickr.com向我提供图片。这种情况下,flickr.com提供的就是一种Web service。如果我把图片都存放在本地服务器,不调用flickr.com,那么我就是在使用"本地服务"。

所以,Web service让你的网站可以使用其他网站的资源,比如在网页上显示天气、地图、twitter上的最新动态等等。

Web Service架构的基本思想,就是尽量把非核心功能交给其他人去做,自己全力开发核心功能。比如,如果你要开发一个相册软件,完全可以使用Flickr的网络服务,把相片都储存到它上面,你只要全力做好相册本身就可以了。
 

最近很红的"云计算"(cloud computing)或者"云服务"(cloud services),实际上就是Web Service的同义词。

四、Web Service的优势
除了本地服务的缺点以外,Web Service还有以下的优越性:
* 平台无关。不管你使用什么平台,都可以使用Web service。

* 编程语言无关。只要遵守相关协议,就可以使用任意编程语言,向其他网站要求Web service。这大大增加了web service的适用性,降低了对程序员的要求。

* 对于Web service提供者来说,部署、升级和维护Web service都非常单纯,不需要考虑客户端兼容问题,而且一次性就能完成。

* 对于Web service使用者来说,可以轻易实现多种数据、多种服务的聚合(mashup),因此能够做出一些以前根本无法想像的事情。

五、Web service的发展趋势
根据我的观察,目前Web service有这样几种发展趋势。
*在使用方式上,RPC和soap的使用在减少,Restful架构占到了主导地位。
*在数据格式上,XML格式的使用在减少,json等轻量级格式的使用在增多。
*在设计架构上,越来越多的第三方软件让用户在客户端(即浏览器),直接与云端对话,不再使用第三方的服务器进行中转或处理数据。
sdfaf

[Web Services] Web Services XML

Web Services

  • Web services are application components
  • Web services communicate using open protocols
  • Web services are self-contained and self-describing
  • Web services can be used by other applications
  • HTTP and XML is the basis for Web services
  • Web Services can be created regardless of programming language
This tutorial introduces WSDL, SOAP, UDDI, and RDF.

Background of Web Services

WSDL

  • WSDL stands for Web Services Description Language
  • WSDL is an XML-based language for describing Web services.
  • WSDL is a W3C recommendation

SOAP

  • SOAP stands for Simple Object Access Protocol
  • SOAP is an XML based protocol for accessing Web Services.
  • SOAP is based on XML
  • SOAP is a W3C recommendation

UDDI

  • UDDI stands for Universal Description, Discovery and Integration
  • UDDI is a directory service where companies can search for Web services.
  • UDDI is described in WSDL
  • UDDI communicates via SOAP

RDF

  • RDF stands for Resource Description Framework
  • RDF is a framework for describing resources on the web
  • RDF is written in XML
  • RDF is a W3C Recommendation

[Web Service] SOAP & SOAP Connection

<SOAP>

Two vendor-neutral standards for accessing web services are REST and SOAP.
REST - Representational State Transfer.
SOAP - Simple Object Access Protocol.



Introduction
  • Simple Object Access Protocol
  • is a protocol specification for exchanging structured information in the implementation of Web Services in computer networks
  • relies on XML Information Set for its message format, and usually relies on other Application Layer protocols, most notably Hypertext Transfer Protocol (HTTP) or Simple Mail Transfer Protocol (SMTP), for message negotiation and transmission. 
  • is platform independent.
  • is language independent.
  • is simple and extensible.
  • Unlike REST, it's a W3C-recommended protocol for web services.
  • SOAP is most often used with HTTP to take advantage of the existing HTTP framework. This also enables calls to bypass firewalls because they pass on the HTTP port - port 80. However, SOAP can also use TCP.

SOAP Syntax

A SOAP message is an ordinary XML document containing the following elements:
  • An Envelope element that identifies the XML document as a SOAP message
    • is the root element of a SOAP message.
    • This element defines the XML document as a SOAP message.
  • [empty] A Header element that contains header information
    • contains application-specific information (like authentication, payment, etc) about the SOAP message.
    • All immediate child elements of the Header element must be namespace-qualified.
  • A Body element that contains call and response information
    • actual SOAP message
  • [optional] A Fault element containing errors and status information for a SOAP message.
Here are some important syntax rules:
  • A SOAP message MUST be encoded using XML
  • A SOAP message MUST use the SOAP Envelope namespace
  • A SOAP message MUST use the SOAP Encoding namespace
  • A SOAP message must NOT contain a DTD reference
  • A SOAP message must NOT contain XML Processing Instructions
For example,
A SOAP  request
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
 <soap-env:Header/>
    <soap-env:Body>
        <cal:schedule xmlns:cal="http://www.example.com/calendar">
            <cal:newitem>
                <cal:eventDate>4/10/2002</cal:eventDate>
                <cal:title>Fun With Frogs</cal:title>
            </cal:newitem>
        </cal:schedule>
    </soap-env:Body>
</soap-env:Envelope>
 

*Notes:
Header element
soap:encodingStyle attribute is optional for SOAP.

Fault element
If a Fault element is present, it must appear as a child element of the Body element. A Fault element can only appear once in a SOAP message.
The SOAP Fault element has the following sub elements:
Sub Element Description
<faultcode> A code for identifying the fault
<faultstring> A human readable explanation of the fault
<faultactor> Information about who caused the fault to happen
<detail>
Holds application specific error information related to the Body element
SOAP Fault Codes The faultcode values defined below must be used in the faultcode element when describing faults:
Error Description
VersionMismatch Found an invalid namespace for the SOAP Envelope element
MustUnderstand An immediate child element of the Header element, with the mustUnderstand attribute set to "1", was not understood
Client The message was incorrectly formed or contained incorrect information
Server There was a problem with the server so the message could not proceed


The HTTP Binding /Protocol 


SOAP Example

A SOAP Request
POST /InStock HTTP/1.1
Host: www.example.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Body xmlns:m="http://www.example.org/stock">
  <m:GetStockPrice>
    <m:StockName>IBM</m:StockName>
  </m:GetStockPrice>
</soap:Body>


</soap:Envelope>


A SOAP Response
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Body xmlns:m="http://www.example.org/stock">
  <m:GetStockPriceResponse>
    <m:Price>34.5</m:Price>
  </m:GetStockPriceResponse>
</soap:Body>


</soap:Envelope>


<SOAP Connection>

A connection is required to send and receive all SOAP messages. The connection can go to a messaging provider or a particular destination.


The JAXM API provides the class and interface to represent two kinds of connections:

A SOAPConnection is a point-to-point connection for sending messages directly to a remote party.
A SOAPConnection object, which represents a point-to-point connection, is simple to create and use. You do not have to do any configuration to use a SOAPConnection object because it does not need to run in a servlet container (like Tomcat) or in a J2EE server. It is the only way for a client to have a connection without a service provider.

A ProviderConnection object represents a connection to a messaging provider. (The next section explains more about messaging providers.) When you send a message via a ProviderConnection object, the message goes to the messaging provider. The messaging provider forwards the message, following the message's routing instructions, until the message gets to the ultimate recipient's messaging provider, which in turn forwards the message to the ultimate recipient.

A messaging provider keeps track of messages and routes them to the correct destination or destinations. It is a service that handles the transmission and routing of messages.


Reference 
http://www.cnblogs.com/chenying99/archive/2013/05/23/3094128.html

http://www.w3schools.com/Webservices/ws_soap_httpbinding.asp

[Web Technology] jQuery

<jQuery>

Introduction of jQuery

jQuery is a light weight JavaScript library which provides fast and easy way of HTML DOM traversing (穿過) and manipulation (操作,運用), its event handling,its client side animations, etc.
One of the greatest features of jQuery is that jQuery supports an efficient way to implement AJAX applications because of its light weight nature and make normalize and efficient web programs.


Explain the features of jQuery?

Features of jQuery are :

  • Effects and animations
  • Ajax
  • Extensibility
  • DOM element selections functions
  • Events
  • CSS manipulation
  • Utilities - such as browser version and the each function.
  • JavaScript Plugins
  • DOM traversal and modification


Why is jQuery better than JavaScript?

  • jQuery is great library for developing ajax based application
  • It helps the programmers to keep code simple and concise and reusable. 
  • jQuery library simplifies the process of traversal of HTML DOM tree
  • jQuery can also handle events, perform animation, and add the Ajax support in web applications.


How to use jQuery?

jQuery can be easily used with other libraries so it should work out of the box with simple and complex JavaScript and Ajax.



What is jQuery connect?




jQuery Mobile

Basic Page Template 
This framework provides a set of touch-friendly UI widgets and an AJAX-powered navigation system to support animated page 


<!doctype html>
<html>
    <head>     
          <title>My Page</title>         
         <meta name="viewport" content="width=device-width, initial-scale=1">     
         <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css">         
         <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>         
         <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>     
    </head>
    <body>     
        <div data-role="page">     
            <div data-role="header">         
            <h1>My Title</h1>     
            </div><!-- /header --> 
 
            <div data-role="content">     
            <p>Hello world</p>     
            </div><!-- /content --> 
     
            <div data-role="footer">         
            <h4>My Footer</h4>         
            </div><!-- /footer --> 
        </div><!-- /page --> 
    </body>
</html>
In the <body>,
a div with a data-role of page is the wrapper used to delineate a page. A header bar (data-role="header"), a content region (data-role="content") and a footer bar (data-role="footer") are added inside to create a basic page (all three are optional). These data- attributes are HTML5 attributes used throughout jQuery Mobile to transform basic markup into an enhanced and styled widget.





Make a ListView
<ul data-role="listview" data-inset="true" data-filter="true">
<li><a href="#">Acura</a></li> 
    <li><a href="#">Audi</a></li>
<li><a href="#">BMW</a></li>
<li><a href="#">Cadillac</a></li>
<li><a href="#">Ferrari</a></li>
</ul>



Add a Slider

<form>
<label for="slider-0">Input slider:</label>
<input type="range" name="slider" id="slider-0" value="25" min="0" max="100" />
</form>
* Notes:
  • Here's a slider made with the new HTML5 input type of range
  • no data-role needed.

Make a Button



Choose a Theme Swatch 



Reference
http://learn.jquery.com

http://www.roseindia.net/ajax/jquery/index.shtml

http://www.w3schools.com/Jquery/default.asp

[Web Technology] Ajax

<Ajax>

Introduction to Ajax
Ajax - Asynchronous JavaScript and XML.

Ajax is a web development technique for creating interactive web applications using a combination of  XHTML (or HTML) and CSS for marking up and styling information. (XML is commonly used, although any format will work, including preformatted HTML, plain text, JSON and even EBML).

Like DHTML, LAMP, or SPA, Ajax is not a technology in itself, but a term that refers to the use of a group of technologies together

The XMLHttpRequest object is part of a technology called Ajax (Asynchronous JavaScript and XML).

Using Ajax, data could then be passed between the browser and the server asynchronously, using the XMLHttpRequest API, without having to reload the entire web page.

In some Ajax frameworks and in some situations, an IFrame object is used instead of the XMLHttpRequest object to exchange data with the web server.

With the widespread adoption of the XMLHttpRequest object it quickly became possible to build web applications like Google Maps, and Gmail that used XMLHttpRequest to get new map tiles, or new email without having to reload the entire page.

Ajax requests are triggered by JavaScript code; your code sends a request to a URL, and when it receives a response, a callback function can be triggered to handle the response. Because the request is asynchronous, the rest of your code continues to execute while the request is being processed, so it's imperative (緊急的) that a callback be used to handle the response.


Most jQuery applications don't in fact use XML, despite the name "Ajax"; instead, they transport data as plain HTML or JSON (JavaScript Object Notation).



What is the disadvantage of Ajax?

Unfortunately, different browsers implement the Ajax API differently. Typically this meant that developers would have to account for all the different browsers to ensure that Ajax would work universally. Fortunately, jQuery provides Ajax support that abstracts away painful browser differences. It offers both a full-featured $.ajax() method, and simple convenience methods such as $.get(), $.getScript(), $.getJSON(), $.post(), and $().load().

In general, Ajax does not work across domains. For instance, a webpage loaded from example1.com is unable to make an Ajax request to example2.com as it would violate the same origin policy.

As a work around, JSONP (JSON with Padding) uses <script> tags to load files containing arbitrary JavaScript content and JSON, from another domain. More recently browsers have implemented a technology called Cross-Origin Resource Sharing (CORS), that allows Ajax requests to different domains.


Does AJAX work with Java? 

Absolutely. Java is a great fit for AJAX! You can use Java Enterprise Edition servers to generate AJAX client pages and to serve incoming AJAX requests, manage server side state for AJAX clients, and connect AJAX clients to your enterprise resources. The JavaServer Faces component model is a great fit for defining and using AJAX components.



Reference
http://learn.jquery.com/ajax/

http://www.withoutbook.com/Technology.php?tech=24&page=3&subject=Ajax%20Interview%20Questions%20and%20Answers

https://www.udemy.com/blog/ajax-interview-questions/

[Web Technology] 2 - Prototype

<Prototype>

Introduction of Prototype
  • It is implemented as a single file of JavaScript code, usually named prototype.js
  • The features range from programming shortcuts to major functions for dealing with XMLHttpRequest.
  • Prototype also provides library functions to support classes and class-based objects.
  • Unlike other JavaScript libraries like jQuery, Prototype extends the DOM


Use $() function to replace document.getElementById(). Like,
var myElement = $(’elementid’);
 
 
Every line of Prototype code has to be carefully rewritten - carefully especially because many helper functions and constructs ($ $$) look deceivingly similar.

[Web Technology] 1 - Dojo

<Dojo>

Introduction
  • Dojo is another great framework or Toolkit for developing ajax based applications. Dojo is selected by Struts 2 for providing ajax support in applications.
  • Dojo is actually based on JavaScript and HTML, so its easy to learn. You can learn Dojo very fast and start developing your next highly interactive web applications.
  • Dojo is the Open Source modular JavaScript Toolkit 
  • It is tool for constructing dynamic web user interfaces 
  • Dojo offers widgets, utilities, higher IO (AJAX) abstraction etc. 
  • BSD (Berkeley Software Distribution) or AFL (Academic Free license) licensed



Latest Version
version 1.9



What are the features / benefit of Dojo

  • Dojo is based on HTML and JavaScript, so its easy for the developers to learn it fast.
  • There is no requirement of learning new programming language. Just HTML and JavaScript knowledge if sufficient.
  • Dojo provides higher abstraction layer to the programmer.  So, it helps the programmers to develop powerful functions very easily.
  • Dojo has already invented the wheels for the programmers and now programmers just have to use the Dojo api into their application


What are the disadvantages of Dojo?

  • Even if Dojo is nice, beautiful etc, it is quite heavy
  • The documentation is still quite narrow
  • Needs much network
  • Developer depends on the browser support for the Dojo
  • There is no way to hide the Dojo code in case of commercial application


What is the basic structure in Dojo?
The basic directory structure of the application is very simple and it will evolve later: 
  • /index.html - The application entry point. 
  • /app - The application module. 
  • /app/main.js - The main script for app module. 


What is the point in Dojo?
  • Dojo bases on the HTML and JavaScript
  • Developer has not to use any strange programming language 
  • Dojo ups abstraction layer in a higher level 
  • Developer has not to reinvent (~ to produce an idea to 在已有事物的基礎上發明) wheel when starting programming project


What is Package System Dojo?
  • Dojo consists of JavaScript files
  • Package system takes care that only needed files are included
  • Each JavaScript file can be named as package dojo.provide(dojo.string)
  • By that name the package can be taken in use dojo.require(dojo.string)
  • One has not to remember any file or directory names
  • Only dojo.js has to be included into HTML document
  • That file takes care of initialization of Dojo
  • There is a couple of pre packaged builds that consist of different kinds of packages e.g. Widget, event or IO builds. 


Tell us about language Libraries in Dojo.
  • dojo.lang.*
  • Wrappers for common idioms
  • Functional programming APIs
  • For Example
    • dojo.lang.forEach
    • dojo.lang.map
    • dojo.lang.assert 


Give some components that comes along with Dojo framework.

  • DOJO Tree
  • DOJO Button
  • DOJO Calendar control
  • DOJO Grid
  • DOJO List box
  • and many more..


TUTORIAL

Hello World Dojo

Getting Start
Getting started with Dojo is as simple as including the dojo.js script in a web page, just like any other JavaScript file. Dojo is available on popular CDNs, so to get started enter the following in a file named hellodojo.html and open it in your web browser.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Tutorial: Hello Dojo!</title>
</head>
<body>
    <h1 id="greeting">Hello</h1>
    <!-- load Dojo -->
            data-dojo-config="async: true"></script>
</body>
</html>

Source: http://dojotoolkit.org/documentation/tutorials/1.9/hello_dojo/

Dojo’s AMD-based module architecture



<Dojo Mobile>

  • Dojo Mobile is a framework that allow you to effortlessly create cross-device-compatible mobile web applications.
  • It is a collection of classes has been architected to be lightweight, flexible, and extendable.
  • Dojo Mobile has also been created to mimic (模仿) the interface of the most commonly used devices: Android, iOS, BlackBerry, WindowsPhone so that your web application is seamless to your user.  
Key features of Dojo Mobile include
  • Complete and consistent mobile widget library (dojox/mobile) -- no need to collect widgets from multiple sources
  • Lightweight, minimal dependencies
  • Native style controls and widgets
  • Same functional behavior on desktop and mobile devices
  • Responds to both orientations as well orientation changes
  • CSS themes for most commonly used device
  • Uses CSS3-based animation where possible



10 Reasons Why Your Projects Should Use the Dojo Toolkit 

Source: http://code.tutsplus.com/tutorials/10-reasons-why-your-projects-should-use-the-dojo-toolkit--net-26072


Dojo Interview Questions

Source: http://www.withoutbook.com/Technology.php?tech=54&page=5&subject=Dojo%20Interview%20Questions%20and%20Answers


Reference:

Dojo API: http://dojotoolkit.org/api/

http://dojotoolkit.org/documentation/

http://dojotoolkit.org/documentation/tutorials/1.6/hello_dojo/

http://www.roseindia.net/dojo/

http://www.javabeat.net/qna/dojo/1/