Search This Blog

Loading...

Thursday, June 12, 2008

Changing default style of <s:actionerror/> / <s:actionmessage/> tag

In struts 2 when you put <s:actionerror /> tag it displays the errors in the following way:

<ul>
<li>error 1</li>
<li>error 2</li>
</ul>


But sometimes it seems to be very ugly when displaying the dot (.) in the action errors or action messages

Below is a normal code that displays the tags in your customized way.
You can specify your own css for this

<s:if test="hasActionErrors()">
<s:iterator value="actionErrors">
<span class="errorMessage"><s:property escape="false" />
</span>
</s:iterator>
</s:if>
Alternatively you can change the file in the "/template/simple/actionerror.ftl” and put it in the /web-directory/struts/simple if using simple theme

Similar for <s:actionmessage /> tag.

Enjoy Struts

10 comments:

Anonymous said...

Hi ,
im getting blank page if i deployed and executed the first sample,im new to struts2 ,i dont know how to run the sample

Anonymous said...

Hi Vinod,

This is very useful programming tip. Thank you.

Regards,
Srinivas

mauvecargo said...

Yes it works fine.

Very good idea, I was exactly seeking for the same stuff.

thanks Vinod

M Georgiev said...

10x Vinod :)

Jthomas said...

THANK YOU SO MUCH!!!

Anonymous said...

Thanks Vinod

Anonymous said...

Thanks Vinod. You are the man.. Keep it up

Anonymous said...

Thanks! The tip was very useful.

Dayanithi Infosys said...

Thanks Vinod
Very much

It is working fine for me

Anonymous said...

Ace, cheers!

Post a Comment