Customising Struts2 JSP tags

March 13, 2009

Here is a possible way to customise the JSP taglib provided by the Struts2 framework.

The topics covered in this post are:

  • add a custom attribute to a given tag (e.g. TextField)
  • customise the Freemarker template to modify the generated HTML code
  • define new themes and templates
  • generate the new TLD for the customised version of the taglib
  • deploy it in a web application (WAR file)

The sample I have created implements a read-only version of the Struts2 JSP taglib: if a given attribute (i.e. viewMode) is set to true then a simple label (plain text) is rendered, instead of the html code for the input type, making the information on the form not editable.

This, in principle, achieves the same purpose as the disabled attribute but it looks much nicer on the web form.

Read the rest of this entry »


Creating a Maven archetype (Struts2/Spring based web application)

February 18, 2009

An archetype in Maven is a template (predefined package structure, resources, configuration files, source files, etc…) which can be used to start the development of a new application.

Amongst various benefits I like the possibility to provide the developers with a set of resources and classes (implementations!) which are going to be needed in the new project. This speeds up the project-setup time and facilitates the adoption of best practises employed within the team.

BTW Maven has few out-of-the-box archetypes (quickstart application, web application, mojo plugin), plus you can find a variety of archetype for lots of frameworks/technology (Struts2, Spring, GWT, etc…).

Here is a list of available archetypes (docs.codehaus.org).

Create a new archetype

The following sections go through the steps of creating a Maven archetype for a web application based on Struts2, Spring and Hibernate (and set of other utilities).

Read the rest of this entry »


XWiki – User Authentication with Oracle SSO

October 15, 2008

XWiki is a popular Java-based wiki software offering a good variety of features and plugins. It is pretty advanced, therefore ideal for any enterprise requiring a content management tool which is flexible, professional and free :-)

Installation and configuration come in different flavors, starting with the standalone distribution (Jetty container on HSQLDB db), by far the easiest option. Alternatively the XWiki WAR file can be deployed on any servlet container and any database of your choice (Oracle 10.1.2 RDBMS and OC4J 10.1.3 in my case).

Read the rest of this entry »


Spring in Action

August 27, 2008

For anybody who is looking to start with the Spring Framework I definitely recommend the “Spring in Action” book. While you find loads of resources on the Web (aka lots of time to be invested) the book has indeed the approach you need if you are a beginner.

The reader is accompanied through the different chapters where the concepts are introduced incrementally and supported by good code samples. Also to be appreciated is the occasional use of UML diagrams to explain the interaction between classes.
It is available on Manning, and definitely worth the 30 bucks.

Part1 Core Spring is by far the most interesting as it covers IoC, bean wiring and AOP. Other chapters present the Enterprise features of Spring, from database access (JDBC and Hibernate) to security, messaging and Web Services. The book has also an introduction to Spring MVC and some words about the integration with other frameworks.

Key features: Easy to read, step-by-step approach, clear code samples.

Make sure it is the 2nd edition (Aug 2007) which is based on Spring 2.


Building XML Web Services with Java: Hands-On

July 29, 2008

Few weeks ago I attended the “Building XML Web Services with Java: Hands-On” training course offered by LearningTree International.

LearningTree

Aside the excellent central location in London and the nice facilities (canteen, coffee corners, Internet access, lab) available to the students I really have to say it is a very good training which I would definitely recommend to anybody who wants to get going with the Web Services and SOA business.

The program of the course covers different aspects related to Web Services with special focus on the standards, protocols and the Java APIs. Read the rest of this entry »