R – Struts errors/messages with div, not span

struts2

We add Struts errors and messages using ActionSupport.addActionError(...) and addActionMessage(...) and then output the results using <actionerror class="x"/> and <actionmessage class="x"/>.

When these tags output the messages they output in the form: <ul><li><span class="x">msg</span></li></ul>

As you can see you can specify the css class (in this example 'x') to apply formatting. Problem is that we want to apply the margin-top and margin-bottom css properties and you can't use these properties (I gather) with <span> elements – only with <div> elements.

So is there anyway you can get these Struts tags to output error/message using a <div> instead of a <span>?

Thanks.


Update:

As per the answer/workaround below, I just enclosed the struts tag within a div:

<div class="error-status">
  <s:actionerror cssClass="error"/>
  <s:actionmessage cssClass="status" />
</div>

The error-status CSS class set the properties on the LI:

.error-status LI { MARGIN-TOP: 5px; MARGIN-BOTTOM: 5px; display: block; }
.error { COLOR: red }
.status { color: #0066CC }

Best Answer

You can apply margin to spans if you also apply display:block.

But the optimal solution is to apply margin to the li elements.

Related Topic