Customizing Spring Roo tagx

DZone 's Guide to

Customizing Spring Roo tagx

I use everyday Spring Roo project to develop Java applications and it offers you the possibility of customizing the code that it generates with the purpose of extending its functioning. I’m going to explain how to do it.

· Java Zone ·
Free Resource

Do You Know How to Customize Spring Roo tagx? 

Spring Roo offers you the possibility of customizing the code that it generates with the purpose of extending its functioning. Sometimes you need to apply modifications over the tagx files defined by Spring Roo, because you need some operations that currently these tagx don’t accomplish. This is the main subject of this article: how can you customize tagx files?

To explain how to do it, I will use an example based on Spring Roo project. You will need:

  • IDE Eclipse STS.
  • An application generated from Spring Roo, for example, a project created using the clinic.roo script.

Spring Roo Console

The reason that I will use it to change a tagx file is that I want to set a default value in inputs and currently this action isn’t supported by the input defined on the Spring Roo project.


Taking into account the possibility of the version of Spring Roo changing while the project is developing, I recommend making a copy of the tagx that you want to modify. When a Spring Roo version in a project is changed, usually you will open the Roo console and you will execute a command to update all the tagx because these could have changed due to improvements developed in the new version. If you don’t have your own copy of the modified tagx, you will lose all your changes.

Update tags

I suggest you place your new tagx file into a folder located in the same level of the originals and give the folder a name similar to the project name. I strongly recommend this name because it is an easy way to identify your own tagx.

New structure

Finally, you need to indicate in your jspx files that you want to use your tagx file instead of the original one. To do that, you have to include the XML namespace with the route where your new tagx is defined. The last change that you will have to make is to modify the reference of the input inside the content of the jspx by the new XML namespace defined.

Use new tag

Hope you enjoy this post and you learn more about Spring technologies.

If you have some comments or questions, feel free to make it, you’ll also find @disid_corp on Twitter.

See you soon!

java, opensource, spring, springroo

Published at DZone with permission of Manuel Iborra . See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}