4 Replies - 1481 Views - Last Post: 13 January 2014 - 03:33 AM

#1 pravin29   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 24-February 13

CSS Style in not being applied to action errors

Posted 12 January 2014 - 11:37 PM

I am using struts 2.3.16

I can see in firebug that css is loadedAttached Image properly but dont why it is not being applied to actionfield errors which i have added in validate method in action class.

Here is my jsp code
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<html>
<head>
<title>Employee</title>
<link rel="stylesheet" type="text/css" href="styles/theme.css" />
</head>
<body>
	<s:if test="hasActionerrors()">
		<div class="errors">
			<s:actionerror />
		</div>
	</s:if>
	<s:form action="login.action" method="post">
		<s:textfield name="username" key="label.username" size="20" />
		<s:password name="password" key="label.password" size="20" />
		<s:submit method="execute" key="label.login" align="center" />
	</s:form>
</body>
</html>


Regards

Is This A Good Question/Topic? 0
  • +

Replies To: CSS Style in not being applied to action errors

#2 Dormilich   User is offline

  • 痛覚残留
  • member icon

Reputation: 4278
  • View blog
  • Posts: 13,561
  • Joined: 08-June 10

Re: CSS Style in not being applied to action errors

Posted 12 January 2014 - 11:57 PM

if you could post the HTML as appearing in the browser, it would be easier to decide, whether the form is inside the div or not.
Was This Post Helpful? 0
  • +
  • -

#3 pravin29   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 24-February 13

Re: CSS Style in not being applied to action errors

Posted 13 January 2014 - 01:43 AM

Here is html source in browser
first three lines are red

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<html>
<head>
<title>Employee</title>
<link rel="stylesheet" type="text/css" href="styles/theme.css" />
</head>
<body>
	
	<form id="login" name="login" action="login.action" method="post">
<table class="wwFormTable">
		<tr>
    <td class="tdLabel"><label for="login_username" class="label">Username:</label></td>
    <td
><input type="text" name="username" size="20" value="" id="login_username"/></td>
</tr>


		<tr>
    <td class="tdLabel"><label for="login_password" class="label">Password:</label></td>
    <td
><input type="password" name="password" size="20" id="login_password"/></td>
</tr>


		<tr>
    <td colspan="2"><div align="center"><input type="submit" id="login_label_login" name="method:execute" value="Login"/>
</div></td>
</tr>


	</table></form>




</body>
</html> 


View PostDormilich, on 13 January 2014 - 06:57 AM, said:

if you could post the HTML as appearing in the browser, it would be easier to decide, whether the form is inside the div or not.


No Form in not is div, here html code in browser source,Its not displaying div


<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<html>
<head>
<title>Employee</title>
<link rel="stylesheet" type="text/css" href="styles/theme.css" />
</head>
<body>

<form id="login" name="login" action="login.action" method="post">
<table class="wwFormTable">
<tr>
<td class="tdLabel"><label for="login_username" class="label">Username:</label></td>
<td
><input type="text" name="username" size="20" value="" id="login_username"/></td>
</tr>


<tr>
<td class="tdLabel"><label for="login_password" class="label">Password:</label></td>
<td
><input type="password" name="password" size="20" id="login_password"/></td>
</tr>


<tr>
<td colspan="2"><div align="center"><input type="submit" id="login_label_login" name="method:execute" value="Login"/>
</div></td>
</tr>


</table></form>




</body>
</html>Attached Image
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich   User is offline

  • 痛覚残留
  • member icon

Reputation: 4278
  • View blog
  • Posts: 13,561
  • Joined: 08-June 10

Re: CSS Style in not being applied to action errors

Posted 13 January 2014 - 03:13 AM

then itís pretty clear. your CSS is depending on a class named "error", but this class is nowhere present in your code, hence the CSS does not apply.
Was This Post Helpful? 0
  • +
  • -

#5 pravin29   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 24-February 13

Re: CSS Style in not being applied to action errors

Posted 13 January 2014 - 03:33 AM

View PostDormilich, on 13 January 2014 - 10:13 AM, said:

then itís pretty clear. your CSS is depending on a class named "error", but this class is nowhere present in your code, hence the CSS does not apply.


Hey found error spot.

I was adding addfield error in validate() methode. but was displaying actionerror
<s:if test="hasActionerrors()">
		<div class="errors">
			<s:actionerror />
			
		</div>
	</s:if>
tag in jsp
instead of that I need to use
<s:if test="hasFieldErrors()">
		<div class="errors">
			<s:fielderror />
		</div>
	</s:if>


CSS is loading properly and also applying but I was using wrong tag thats why it was not displaying.

thanks though buddy.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1