Warp :: Getting started

Warp is currently beta and licensed under Apache 2.0.

[   Warp    Source    Download    Troubleshooting    Email   ]

Getting started with Wideplay's Warp Framework

First download warp and its dependencies from the link provided above. For convenience, dependencies are packaged along with the warp core library in a zip file named warp-with-deps.zip. Unzip and place the provided jars into your application's WEB-INF/lib folder. Create a web.xml file in WEB-INF, and add the following filter mapping to it:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >



Note that the parameter warp.module must specify the class name of your Warp Module class. This is typically a class that looks like so:

package my.example; 

public class MyModule implements WarpModule {
 	public void configure(Warp warp) {
		//nothing required yet

Now, this tells Warp to look in package my.example for page classes (and resources) to register to the runtime. Every class in the WarpModule's package and its sub-packages are considered candidates for page object registration (but only those that have corresponding templates are typically registered). You can also perform a lot of setup work in the WarpModule as we will see later on. 

In Warp, a page is represented by a page object, and any manipulation of that page or its state is driven from the page object. OK, let's create a simple page to say hello to the world:

package my.example;
public class Start {
 	private String message = "hello warp!";
 	public String getMessage() { return message; } 

In Warp, page objects are always be accompanied by a template (in this case a standard HTML template) to tell Warp how to decorate and layout the content in the page. As a convention, templates are named the same as page classes (in our case, Start.html in the / directory):

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns:w="http://www.wideplay.com/warp/schema/warp_core.xsd"
xml:lang="en" lang="en">

<title>Warp :: Hello World</title>

<body w:component="frame">

Note that the only unusual part about this template is the attribute on body named w:component which tells Warp to decorate the <body> tag with a Frame component. The Frame component is used on nearly every page and is a kind of "wrapper" for the page (and should always be present on the <body> tag) which creates some necessary conditions for the rendering of the page by the Warp framework.

The other noteworthy part of the template is the ${message} expression, which is a property expression telling Warp to look into the corresponding page object for a property named message. If you look above, we've declared message as a String in our Start page class. 

You should now have a web application with roughly the following structure:

	 - Start.html 
	 - WEB-INF/
		- web.xml
		+ lib/
		+ classes/

Running the web aplication and pointing your browser at http://localhost:8080/Start now will produce the following page output:







Next: A blog application.

Contribute to the Warp Framework

Get involved! Email me on the Warp mailing list if you want to help or have a problem to report. Problems with Guice should be reported on the Guice user mailing list.