user3805315
user3805315

Reputation: 33

How to avoid addActionMessage showing on all pages

addActionMessage(" does not exist!");

How to avoid this message in JSP page showing all pages.

JSP:

<s:actionerror cssClass="MessageBox" theme="simple" />
</s:if> 

 <s:if test="hasActionMessages()">
     <s:actionmessage cssClass="MessageBox" theme="simple" />
 </s:if>

Upvotes: -1

Views: 333

Answers (3)

Roman C
Roman C

Reputation: 1

If the action has action messages then they will be shown. You need to change the logic to decide whether action messages should be shown. Create a method in the action class that returns boolean and is called when you need to test it. For example

private boolean showActionMessages;

public boolean isShowActionMessages(){
  return hasActionMessages() && showActionMessages;   
}

then change the if tag

<s:if test="showActionMessages">
     <s:actionmessage cssClass="MessageBox" theme="simple" />
</s:if>

Upvotes: 0

hari
hari

Reputation: 1963

ActionMessage is also Collection<String> getActionMessage() {... }.so you can use iteator method.try this,

    <s:iterator value="actionMessage" status="s">
          <s:set var="S1" value="%{actionMessage.get(#s.index)}"/>
              <s:if test="#S1.contains(' does not exist!')">
                    True
               </s:if><s:else> 
                     False
                </s:else>
     </s:iterator>

Upvotes: 0

xrcwrn
xrcwrn

Reputation: 5327

I think you have added addActionMessage(" does not exist!"); in all action method You should use different messages in each method of action class to get diffetent messages.

Upvotes: 0

Related Questions