Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid actionMessages/actionError generating ul li tags?

In my Struts 2 application following tags generating ul li span tags, I have to avoid it. How it could possible? I am also used theme="simple", it doesn't work.

<s:actionmessage />
<s:actionerror />
like image 273
rpandidurai Avatar asked Jul 25 '14 12:07

rpandidurai


2 Answers

Use iterator tag to iterate actionMessages or actionErrors. The action should extend ActionSupport.

<s:iterator value="actionMessages">
  <s:property/><br/>
</s:iterator>

<s:iterator value="actionErrors">
  <s:property/><br/>
</s:iterator>
like image 116
Roman C Avatar answered Nov 18 '22 00:11

Roman C


Iterate them and print each message / error manually, with the HTML you like:

<s:if test="hasActionMessages()">  
    <div id="messagesDiv" style="border: 10px solid green;">
        <s:iterator value="actionMessages">
            <span class="actionMessage">
                <s:property />
            </span>
        </s:iterator>
    </div>
</s:if>

<s:if test="hasActionErrors()">  
    <div id="errorsDiv" style="border: 10px solid red;">  
        <s:iterator value="actionErrors">  
            <span class="errorMessage">
                <s:property />
            </span>  
        </s:iterator>  
    </div>  
</s:if>

The <span> (or some other tag) should be kept, in order to semantically separate the messages (to decorate them with a different CSS style tomorrow, for example, which you are unable to do by printing them as simple text).

Otherwise, simply remove the <span> and add a <br> after the <s:property/>

like image 41
Andrea Ligios Avatar answered Nov 18 '22 01:11

Andrea Ligios