Tapestry

Tapestry part VII - Wrap Up

Introduction

In this blog series we presented various blogs on Tapestry with the goal to show how to build a simple "Hello World" style application that gives GUI using HTML pages and presents a WEB API. By using Stream Response it's possible for Tapestry to return a stream, and with that we build a simple API. Testing this setup is a little involved and explained in detailed in the last blog of the series. We present a short overview of the blogs here. Continue reading

Tapestry part VI - Testing a WEB API

Introduction

In this blog we will show how a WEB API created using Tapestry can be tested. Testing a web service is not straight forward as the PageTester, the default way of testing in Tapestry, doesn't allow for testing API. To overcome this difficulty we must start a Jetty server with custom/test web.xml. The test web.xml allows us to control the construction of objects. In this example we show how a mock service object can be inserted for testing, while using the full implementation for production.

This blog is part of a series of blogs on Tapestry that explains how to build a "simple" hello world example html page and expose the functionality of the page(s) via a WEB API. In a previous blog we showed how to setup a web API that responses in either XML or JSON. If you haven't read it yet, it's probably a good idea to have a look at this blog first before proceeding.

This blog picks things up from another previous blog in the series on testing page. The basic of testing a webpage generated with Tapestry are explained there. In this blog we will build on the code previously created.

Prerequisites

Continue reading

Tapestry part V - Testing a page

Introduction

In this blog we will demonstrate how to test a webpage within the Tapestry framework. The framework comes with a few handy testing options. Here we will consider the PageTester object, which can be used to replicate interactions between user and application. It deals with all input and output on the pages. As such it is great for User Acceptance Testing and Unit Testing. To show how to use the PageTester we will add some tests to the Hello Tapestry example of the first blog in the series.

Prerequisites

Continue reading

Tapestry - Part IV: Extended API using XML

Introduction

In a previous blog in our Tapestry series we showed that Tapestry can be used as an API. While we would advice to do this only for simple cases, it could be a good solution if you wanted to offer Web API for your existing Tapestry application. If you were interested in a fully-fledged Web API with all the bells and whistles it would probably be better to use a separate framework.

In a previous blog we build an API returning JSON. This raises the question: is it also possible to return XML? The answer turns out to be yes!

In this blog we will show how to do so.

Prerequisites

Continue reading

Tapestry - Part III: Input Validation

Introduction

In previous blogs we showed how to setup a simple “hello world” web application using Tapestry including an API. One of the issues we ran into is that some names are reserved in the application for page names, so they can’t be used as input names for the application. Here we will show how the input can be filtered and meaningful error messages can be created for the user. This approach allows you to create a better user experience and safer applications.

Prerequisites

Continue reading

Tapestry - Part II: Simple WEB API using Tapestry

Introduction

In this blog we will show you how to extend your Tapestry projects with a simple API. If you have a big project and need complex calls to expose your API functions, then this approach is not for you. Instead, if you have a couple of functions you would like to expose, this is a quick and simple approach to get it done.

Prerequisites

  • This tutorial uses Eclipse with Maven
  • This tutorial builds on previous blog

We consider a setup where a request to \\example.com\api should be replied with a JSON stream, where stream is just fancy way of saying text file. To do this in Java there are a few very good frameworks:

The last one is the easiest complete-integration framework for REST API that will work with Tapestry that we could find. However, if your have very simple requirements even the out-of-the-box frameworks might not be worth configuring. The alternative is to parse arguments during the rendering of a page and respond with XML or JSON. In this example we’ll show how to create an API for our hello-world application, which we build in our previous blog. Continue reading

Tapestry - Part I: Hello Tapestry

Introduction

Tapestry 5 is framework for creating web applications using Java. The framework allows you to generate HTML pages using Java code. This a good thing if you have complex business logic that takes data from the user, database, online resources to present a result as a webpage. We wanted to do something like that for one of our econometric models so we decided to give Tapestry a go for building our web application. Along the way we learned quite a lot about the framework. Some of that we want to share here in a series of blogs. The complete series should be enough to build simple GUI for your Java business logic.

In this blog we will create a hello-world style example using Tapestry 5. The goal of this example is to get you up and running with Tapestry using the skeleton setup that is included with Tapestry. Based on this initial setup we will make changes to get a hello-world page.

Prerequisites

  • This tutorial uses Eclipse with Maven

Continue reading