tags:

views:

433

answers:

1

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 }
+1  A: 

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

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

Chetan Sastry
Thanks Chetan. It appears that using display:block with span only works on IE - not on Firefox.
Marcus
Yes, because span is meant to be an inline element. Masquerading it as a block element is non-standard. That is why the optimal solution is to add margins to li.
Chetan Sastry
Thx for your help Chetan.
Marcus