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

Using Safari To View XML Files

This blog explains how to get nicely-formatted XML in the Safari browser.

Introduction

Recently we have been writing a series of blogs on the Tapestry framework showing how it can be used to create web applications. One of the blogs explains how to get the framework to return XML response for API integration. While creating the example we noticed that on OSX the Safari browser didn't give us back nicely-formatted XML files (see example)

initial in safari default.

 

In other browsers we did get the expected result. Since for most of the series we had been using screenshots from the Safari browser to illustrate the expected results, we wanted to stick with this browser. As it turns out, you can get nicely-formatted XML files in Safari, however this requires an additional one-time setup. 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