cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörn Heid <h...@hs-heilbronn.de>
Subject AbstractAnnotationAction for Cocoon 2.x
Date Fri, 03 Jul 2009 11:19:19 GMT
Hi.

I've written a simple class which may help others writing Actions with 
lesser code. Feel free to use it  (and expand it) if you like it.

An example:

public class TestAction extends AbstractAnnotationAction {

 @ActionMethod
 protected void doMyAction (@SitemapParam("my-param") 
@DefaultValue("true") boolean myParam,
                                             @QueryParam("login") String 
login,
                                             @QueryParam("counter") 
@DefaultValue("0") int counter;
                                              Session session) {
     System.out.println ("Login: "+login);
     }
}

You can use @QueryParam, @SitemapParam, @ConfParam, @HeaderParam, 
@CookieParam, @FileParam. In the signature of the method you can just 
add variables if you need them: Request, Session, Redirector, Response, 
ResultHashMap, Conext, SourceResolver. All of them will be set 
automatically.
All parameters are casted when needed.

The method to be invoked must have a @ActionMethod annotation or you can 
define the method using "_method" request or sitemap parameter.

Cheers,
Jörn

Mime
View raw message