You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by james billa <ja...@gmail.com> on 2009/10/09 18:25:03 UTC

Do something based on existence of action error - How?

Hi ,

I am using Struts 2.1.6. I want to show the content  a <tr> only if action
error exists. If not I don't want to show the content of my <tr>. How do I
check whether action error exists or not in my page? The action error is set
by my action class if there is an error.

I have done to coding (CSS) to show or hide the <tr>. But not sure how to
implement it by checking the action error. Thanks.

Thanks
JB

RE: Do something based on existence of action error - How?

Posted by Mike Baranski <li...@secmgmt.com>.
I put the following in a DIV at the top of every page:

<%@ taglib prefix="s" uri="/struts-tags" %>
<s:include value="/pages/common/jsps/header.jsp" />
<body>
		<div id='top_div'>
			<h1><s:text name="co_title"/></h1>
			<s:include value="/pages/common/jsps/menu.jsp" />
		</div>
		<div id="body_div">
			<s:if test="hasErrors()">
				<h1 class="error"><s:property
value='getText("co_error")'/></h1>
				<ul>
					<s:if test="hasActionErrors()">
						<s:iterator
value="actionErrors">
							<li
class="error"><s:property/></li>
						</s:iterator>
					</s:if>
					<s:if test="hasFieldErrors()">
						<s:iterator
value="fieldErrors">
							<s:iterator
value="value">
								<li
class="error"><s:property/></li>
							</s:iterator>
						</s:iterator>
					</s:if>
				</ul>
		</div>
		</s:if>
		<s:include value="/pages/common/jsps/footer.jsp" />


>-----Original Message-----
>From: james billa [mailto:jambilla@gmail.com]
>Sent: Friday, October 09, 2009 12:25 PM
>To: user@struts.apache.org
>Subject: Do something based on existence of action error - How?
>
>Hi ,
>
>I am using Struts 2.1.6. I want to show the content  a <tr> only if
>action
>error exists. If not I don't want to show the content of my <tr>. How do
>I
>check whether action error exists or not in my page? The action error is
>set
>by my action class if there is an error.
>
>I have done to coding (CSS) to show or hide the <tr>. But not sure how
>to
>implement it by checking the action error. Thanks.
>
>Thanks
>JB


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org