Hello all,
couple words about this post and what's all this for and about.
I'm totally new to Java, sometime ago one «unknown java developer» told me a lot of Java and wonders of Tapestry 5, so I've decided to pick some knowledge up.
My first impression of Java world was just a shock, too many ways and variants, too many «TLAs» («Three letter acronyms», see the t5-tutorial ). I've suffered of lack of simple and clear tutorials for «newcomers» - only all those «it's very simple», «it's so clear that I won't explain» and so on. So, the purpose of this particular post is to share some «new to Tapestry 5» experience.
First, I suggest to read the t5-tutorial (it's small and incomplete but still) and have a look at ApacheTapestry pages (screencasts are very helpful at the beginning).
Second, I'd like to write a very simple t5 web-application, e.g. only several pages like Login, Home, Add/Edit User, sort of CRUD functionality. I found some information about user authentication in Tapestry 4 and some sample code on tapestry-core pages , think it might help.
For the start, we need to install all the tools we need. Don't forget to add JDK and maven location to your PATH variable (for Windows users only, Linux and MacOS have their own settings).
At the moment current T5's version is 5.0.4 but it has some issues with downloading etc, so. Let's use 5.0.3. Create a tapestry simple project (see the screencasts and tapestry-quick start page ). Name the new application as org.example.TSA503 (Tapestry Simple Application, one more TLA ;) )- run following from the command line:
mvn archetype:create -DarchetypeGroupId=org.apache.tapestry -DarchetypeArtifactId=quickstart -DarchetypeVersion=5.0.3 -DgroupId=org.example -DartifactId=TSA503 -DpackageName=org.example.TSA503 -Dversion=1.0.0-SNAPSHOT
Hope, you will see BUILD SUCCESSFUL.
Open and run generated project in eclipse . Don't be too confused, the 5.0.3 quickstart project contains several "errors" -find the /TSA503/src/main/java/org/example/TSA503/services/AppModule.java file, find and remove following lines:
import org.apache.tapestry.ioc.annotations.Contribute;
import org.apache.tapestry.ioc.annotations.Id;
@Id("app")
@Contribute("tapestry.ioc.ApplicationDefaults")
@Contribute("tapestry.RequestHandler")
Now, you can play a bit with the Start page to see some features shown in the screencasts.
Create new HTML file in /TSA503/src/main/webapp/WEB-INF/ - Login.html
Navigate to the Input validation page , copy login page html code from «Configuring Fields and Labels» and paste it into your new /WEB-INF/Login.html.
After that, create a new class, the login page class, in /TSA503/src/main/java/org/example/TSA503/pages/ - Login.java. Have a look at the class Login at the «Storing Data Between Requests» section, we will use it a bit later just for now Login.java might look like this.
Save all, run the application on jetty and open http://localhost:8080/TSA503/login in a browser. You'll see your Login page, now you can test it a little, how does the validation work, what's the navigation flow etc.
After all above, I suggest to add several small modifications to the application. - don't stop the server, find the Start page template in /TSA503/src/main/webapp/WEB-INF/Start.html, find the
[<a t:type="PageLink" page="Start">refresh </a>]
there and add the following:
<br/>
[<a t:type="PageLink" page="Login">Login </a >]
to get the:
[<a t:type="PageLink" page="Start">refresh </a>]
<br/>
[<a t:type="PageLink" page="Login">Login </a>]
Open http://localhost:8080/TSA503/start in your browser and see the changes, now you can get your Login page directly from the Start page.
So, the first step is very simple, it's only shows the very basics, but I hope it can be useful for anybody who wants to know more.
Constructive comments and corrections are welcomed :).
Next step - adding the UserAuthenticator service into the project.
6. SimpleTapestry 5 CRUD application -Step 06, tweaking a grid a bit.
5. Simple Tapestry 5 CRUD application - BeanEditForm and Grid screencasts aprobation.
4. SimpleTapestry 5 CRUD application -Step 04 Adding some basic Hibernate features into the project.
3. SimpleTapestry 5 CRUD application -Step 03, "user" bean creation.
2. SimpleTapestry 5 CRUD application -Step 02, adding a service.
1. SimpleTapestry 5 CRUD application -Step 01.