Showing posts with label stripes. Show all posts
Showing posts with label stripes. Show all posts

Saturday, March 19, 2016

HTML5 tags for Stripes

Introduction

In a previous article, we explained how to implement HTML 5 tags for Struts v.1 framework. We won't explain in this article the new attributes that came with HTML 5. For this, please refer to the Struts article, linked above. As Stripes is another framework I use on side projects, let's see now how to implement the same features, extending existing Stripes existing tags!

Stripes tag implementation


As we investigated about the best implementation for the new tags in Stripes source code, I noticed all tags extend an abstract HtmlTagSupport class. This class contains an attributes field, which simply is a Map containing attributes names and values of the current tag :



The idea for the implementation will be quite simple : our new classes will "only" have to add new attributes to this existing Map!

To keep example simple, we will only extend one tag (text), and add three attributes for each (required, pattern, and placeholder). What we do here is just add getters and setters for the attributes, and in these, we set/get the values from the attributes Map :

Once done, we must declare the new classes to a .tld file. As our class extends existing tag, the tag declaration will be copied from existing Stripes tld file, with our new attributes listed at the end of the file :

See the result in action :

If you have any questions regarding this article, please send them in the comment box below!

Friday, October 30, 2015

Spring integration with Stripes 1.6.0

Introduction

Stripes is a small but powerful MVC framework, and I use it on my free time project. Version 1.6.0 was released some weeks ago, and it introduced a change that is likely to break your application if you use its legacy built-in Spring integration.

SpringInterceptor class is not available anymore from version 1.6, and after upgrade from previous releases, you might notice some Exceptions such as :

Could not find class [net.sourceforge.stripes.integration.spring.SpringInterceptor] specified by the configuration parameter [Interceptor.Classes]. This value must contain fully qualified class names separated  by commas.


Solution

In order to get Spring integration working again, you have to modify your web.xml file : add net.sourceforge.stripes.integration.spring to Extension.Packages entry, and remove net.sourceforge.stripes.integration.spring.SpringInterceptor from Interceptor.Classes entry:


Rebuild your project, and it should be working fine. Just drop a comment below if you have any question!