- Context Framework
-
Context Framework Stable release 0.8.4 / August 23, 2011 Written in Java Operating system Cross-platform Type Application Framework License Apache License 2.0 Website contextfw.net The Context Framework is an open source component based web framework for the Java platform and it has similarities with Apache Wicket and Lift.
Contents
Design
The goal of Context is to create a flexible and lightweight framework based on XSLT-templating language. All pages are a tree of components (including the page-component ifself) and during rendering they form a single DOM-tree that is transformed into XHTML. The choice creates a sharp separation between logical representation and physical representation and only very little logic is possible to present on XSLT-templates.
Second aspect is that all interaction and page updates are javascript based. For instance traditional form-submits are not encouraged, however they are possible if needed. Third, the component-model is designed in such way that each component is able to update their content independently from other components. This enables complex interaction between page components.
Pages themselves are normally made of multiple views that are nested. With this approach the outer views can concentrate to general content such as HTML-decrations or menus. Outer views also generate a natural perimeter for authentication so that only authenticated users are allowed to access inner views.
Framework is also highly stateful, where each page instance has their own state on server. This is called a page scope. The goal was to create page state in such manner that it does not interfere with having multiple open pages on same site. A speciality for mainting the page scopes is that no cookies or session is used.
Even if framework is considered stateful, creating new pages is lightweight operation thus making Context suitable for small sites or large web applications.
Context support full live class reloading to pages and their components during development mode. It allows new set of compiled classes to be loaded into system during page loads thus minimizing the need for complete system restarts. The live class reloading can be extend singletons-scoped instances if designed carefully.
Example
A Hello World view, containing two files:
- HelloWorldView.java
- The Java-component for the page
@PageScoped @View(url="/helloworld", parent=OuterView.class) public class HelloWorldView extends Component { @Attribute private Date currentTime = new Date(); }
When rendered this component translates into following DOM-tree snippet:
<HelloWorldView id="el1" currentTime="...." />
- HelloWorldView.xsl
- The template for the view
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="HelloWorldView"> <h1>Hello World!</h1> <p> Current date is: <xsl:value-of select="currentTime" /> </p> </xsl:template> </xsl:stylesheet>
See also
External links
Categories:- Java libraries
- Web application frameworks
Wikimedia Foundation. 2010.