Java view technologies and frameworks: Difference between revisions

Content deleted Content added
No edit summary
 
(91 intermediate revisions by 60 users not shown)
Line 1:
{{Short description|Programming language and libraries}}
'''Java view technologies and frameworks''' are [[web-based]] [[software libraries]] that provide the [[user interface]], or "[[Model–view–controller|view-layer]]", of [[Java (programming language)|Java]] [[web application]]s. Such [[application framework]]s are used for defining [[web page]]s and handling the [[HTTP]] [[List of HTTP header fields#Requests|requests]] (clicks) generated by those web pages. As a sub-category of [[web framework]]s, view-layer frameworks often overlap to varying degrees with web frameworks that provide other functionality for Java web applications.
 
Java view-layer frameworks often claim to support some or all of the [[model–view–controller]] design pattern.
 
==At a glance==
{| class="wikitable" border="1"
|-
! Action-based frameworks:
! HTTP Paradigm
| [[Apache Struts]], [[Spring Framework|Spring MVC]]
! Component Paradigm
! Templating
|-
! Component-based frameworks:
| Struts
| [[Apache Click]], [[Apache Tapestry]], [[Apache Wicket]], [[Jakarta Faces]]
| Wicket
| Tiles
|-
! Web template systems:
|
| [[Apache Tiles]], SiteMesh, [[Thymeleaf]]
| Tapestry
| SiteMesh
|-
|
| JSF
| Facelets
|-
|
|
| Click
|}
 
* Struts is relatively easier to use for beginners because it contains the familiar HTTP paradigm of Request/Response. However, the Component based frameworks are architecturally superior, and usually recommended for creating more complex [[web application]]s.
* [[Jakarta Faces]] (JSF), [[Apache Tapestry]] and [[Apache Wicket]] are competing component-based technologies, abstracting the [[Stateless protocol|stateless]] HTTP request-response cycle and the [[Jakarta Servlet]] [[API]] behind an [[Object-oriented programming|object-oriented]], event-driven component model.
* Wicket, Tapestry and JSF are competing technologies.
* In contrast, Struts and the [[Spring Framework|Spring MVC Framework]] are action-oriented frameworks that provide a thinner [[abstraction layer]] over the servlet [[API]].
* Tiles is a templating framework which is designed to work with Struts.
* Apache Tiles is a templating framework designed to work with Struts.
* SiteMesh can be used with any JSP.
* [[Facelets]] is a view definition and templating technology designed to work with JSF.
* SiteMesh can be used with any [[Jakarta Server Pages|Jakarta Pages]] (JSP).
* Wicket and Tapestry have their own native templating.
* Facelets, Tapestry and Wicket have their own templating approaches based on [[HTML]]/[[XHTML]].
* Click uses HTML based velocity templates and plain old Java objects. JSP is optional.
* [[Apache Click]] uses HTML based [[Apache Velocity]] templates and [[plain old Java object]]s (POJOs), with JSP optional.
 
==Servlet API==
{{main |Jakarta Servlet}}
* This is the foundation of almost all Java View technologies.
 
* It provides the basic framework for writing Java classes, called 'Servlets' that can respond to HTTP R
The Servlet API is the foundation of almost all Java Web View technologies. Servlet provides the basic mechanism for writing Java [[class (computer programming)|class]]es for web applications. Servlets can respond to HTTP requests, create cookies and maintain sessions.
==JSP==
 
* Built on top of the Servlet API, JSP provides for a HTML centric Server [[Parallel programming model|programming model]].
==Jakarta Pages (JSP) ==
* Java code is embedded in the JSP files and is executed when a request is received.
{{main |Jakarta Server Pages}}
 
* Built on top of the Servlet API, JSP provides a document-centric, tag-based templates, server programming model which can generate many forms of textual content.
* Java code may be embedded in JSP files and is compiled and executed when a request is received.
 
==Apache Struts==
{{main |Apache Struts}}
 
* Struts provides for a [[coupling (computer programming)|decoupling]] of the Controller and the View.
==Struts==
* Built on top of the Servlet API, Struts provides for decoupling between the Controller and the View.
* Requests are received by a Java Class (Controller) which can decide which View to display.
* The actual View iscan be written asin adifferent view technologies, like JSP, free marker template, velocity template pageetc.
* An XML [[configuration file]] is used to specify the "Page Navigation", i.e. the flow of the request to the appropriate Controller, and which View to display based on the outcome of the Controller.
* '''Competitor''': Spring MVC, Grails
* '''Competitor''': Though Struts does not have any direct competitor in its league, Component View Technologies (like Wicket, Tapestry) are generally accepted as superior.
 
==TilesApache Tapestry==
{{main |Apache Tapestry}}
* This is a HTML templating framework based on the "Composite" model.
 
* It allows for the HTML page to be broken up into multiple pagelets, called Templates, Definitions and Composing pages.
* A component-based view framework.
* At [[run time]] the pagelets are stitched together to generate the final HTML. Pages are written in JSP.
* Classes are written as POJOs and byte-code transformed at runtime
* Configured with annotations and naming conventions rather than XML
* Compared to JSPs, enforces a clear separation of [[HTML element|HTML markup]] and Java code.
* HTML templates can be directly previewed by web designers
* Changed component classes are live-reloaded into running application for faster development.
* Uses the [[Post/Redirect/Get]] navigation pattern for form submission.
* '''Competitor''': Wicket, JSF
 
==Apache Tiles==
{{see also |d:Special:EntityPage/Q28912908|l1=Apache Tiles}}
 
* This is an HTML templating framework based on the [[composite pattern]].
* It allows for the HTML page to be broken up into multiple "pagelets", called Templates, Definitions and Composing pages.
* At [[runtime (program lifecycle phase)|runtime]] the pagelets are stitched together to generate the final HTML. Pages are written in JSP.
* '''Competitor''': SiteMesh
 
==Apache Wicket==
{{main |Apache Wicket}}
 
* A component-based view framework.
* Pages directly interact with stateful Java components on the server.
* Components and their state are managed by the Wicket framework, freeing the application developer from having to use HttpSession directly to manage state.
* Does not require XML for configuration.
* Compared to JSPs, enforces a clear separation of [[HTML element|HTML markup]] and Java code.
* Web page components are 'pushed' into the HTML markup from the code.
* '''Competitor''': Tapestry, JSF
 
==Jakarta Faces and Facelets==
{{main |Jakarta Faces}}
 
* A specification for component-based view frameworks.
* [[Eclipse Mojarra]] and [[Apache MyFaces]] implementations are available
* Typically uses Facelets for XML/XHTML-based templating.
* Classes are written as POJOs, with Annotations or XML configuration files used to associate them with page and component templates.
* The [[Unified Expression Language]] allows binding component fields and events to POJO bean properties and methods.
* Conversion and validation constraints can be specified in Facelets and are automatically applied, normally resulting in reposting of the same page with error information in case of failure.
* Navigation can be via configuration file rules or directly specified in the page.
* Can transparently support [[Ajax (programming)|Ajax]].
* '''Competitor''': Wicket, Tapestry
 
==SiteMesh==
{{main |SiteMesh}}

* [[SiteMesh]] is aan HTML templating framework based on the "Decoration" model.
* It allows for the creation of a 'decoration' template which is then applied to any other HTML to generate a new HTML.
* The newly generated HTML contains elements from the original HTML blended into the template.
Line 60 ⟶ 100:
* '''Competitor''': Tiles
 
==WicketSpark==
{{main |Spark (software)}}
* [[Apache Wicket|Wicket]] provides a 'Component' view technology - meaning the Request-Response Stateless paradigm of HTTP is abstracted away to give rise to an [[Object-oriented programming|Object Oriented]] Stateful paradigm.
* Pages now directly interact with Stateful Java Components on the server.
* Components and their State are managed by the [[Wicket framework]], freeing the application developer from having to use HttpSession directly to manage state themselves.
* Further, Wicket provides for a clear separation of [[HTML element|HTML markup]] from code, and there are no XML configuration files to manage.
* Web page components are 'pushed' into the HTML markup from the code.
* '''Competitor''': Tapestry, JSF
 
* Spark a micro web framework built around a simple routing system
==Tapestry==
* It runs on an embedded [[Jetty (web server)|Jetty]] web server by default, but can be configured to run on other webservers.
* [[Tapestry_(programming)|Tapestry]] provides a 'Component' view technology.
* It supports three different templates engines: [[Apache Velocity|Velocity]], [[FreeMarker]] and [[Mustache (template system)|Mustache]]
* Classes are written as POJOs and Annotations are used to configure them as Tapestry components.
* It aims to facilitate rapid development, and does not make use of annotations or proprietary solutions.
* HTML components can directly refer to the component methods and attributes.
* '''Competitor''': Wicket, JSF
 
==See also==
{{Portal|JavaComputer programming}}
* [[List of web service frameworks]]
<!-- formatting; please do not remove until some more text lines are added to compensate spacing -->
* [[List of Java frameworks]]
 
==References==
* [[Java Servlet]] Technology (http://java.sun.com/products/servlet/)
* [[JavaServer Pages]] Technology (http://java.sun.com/products/jsp/)
* [[Apache Struts]] 2 Documentation (http://struts.apache.org/2.1.6/docs/home.html)
* Apache Struts Tiles (http://struts.apache.org/1.x/struts-tiles/)
* [[Click Framework]] Project Documentation (http://incubator.apache.org/click/)
 
[[Category:Java (programming language)]]
[[Category:Java APIs]]