To start using Wheel, all you need is a working build that will produce a web application (eithter exploded or packaged .war) that contains Wheel dependencies in WEB-INF/lib and a web.xml file that looks like this:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <servlet> <servlet-name>wheel</servlet-name> <servlet-class>wheel.WheelServlet</servlet-class> <init-param> <param-name>basePackageForPages</param-name> <param-value>samples.pages</param-value> </init-param> <init-param> <param-name>applicationPackages</param-name> <param-value>samples.pages</param-value> </init-param> <init-param> <param-name>developmentMode</param-name> <param-value>true</param-value> </init-param> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>wheel</servlet-name> <url-pattern>/app/*</url-pattern> </servlet-mapping> </web-app>
If Wheel artifacts are not yet available in a public m2 repository, there's a shell script available in the root of the distribution package that will install the required dependencies to your local repository. The samples application uses Maven2 and this step is a pre-requirement for running it.
Once you've set up a development environment, let's create the classic Hello World application.
package samples.pages; import wheel.components.StandaloneComponent; public class Home extends StandaloneComponent { public void buildPage() { h1("Hello World!"); } }
The samples application uses Maven2. If you don't have Maven2 installed, you can download it from the Maven2 site Before running the samples applicatiton, you must install required dependencies to your local repository. This can be done with the .bat/.sh script in the root directory.
Open a command line console and go to the samples directory. Then use this command:
mvn jetty:run
Open your browser and use the address: http://localhost:8080/samples/app.
When you make any changes to the source classfiles or create new ones, leave the jetty console open, open another console, go to the samples directory and use this command:
mvn compile
Then refresh your browser to see the changes.