February 9, 2010 | In: computer engineering

How to custom print actionErrors / fieldErrors with Velocity on Struts2

struts2-merger2

Just a quick code snippet, that couldn’t find anywhere on the net as an example and my colleague Aggelos offered to me :)

#if( $actionErrors.size() > 0 )
#foreach( $msg in $actionErrors )
[$msg]<br/>
#end
#end

Same for fieldErrors. Use them instead of the default #sactionerror , #sfielderror etc to produce custom html. If you only need css formatting, override your css as described in the comments on this webpage. Of course, you can always override the default freemarker template for errors on the struts jar file, to provide uniform handling of error formatting

  • Share/Bookmark

Comment Form

Me social

twitter: thkouk
facebook: thkouk
linkedin: thkouk
picassaweb : thkouk
youtube: thkouk
friendfeed: thkouk
delicious: thkouk

 

February 2010
M T W T F S S
« Jan   Mar »
1234567
891011121314
15161718192021
22232425262728