ActionErrors displayed twice

B

beenamore

Hi All,

I am new to struts.

I am trying to do some client side validations by overriding the
validate method in the ActionForm class and display the ActionErrors
for a property right next to the fields.

public ActionErrors validate(ActionMapping mapping,
javax.servlet.http.HttpServletRequest request) {

ActionErrors errors = new ActionErrors();

if(institutionName == null || institutionName.length() == 0)
{
errors.add("institutionName",
new ActionError("error.required", "Institution Name"));
}
return errors;
}

In my JSP, if the field is missing I want to display the ActionErrors
next to the filed.

<html:form action="/addInstitution" focus="institutionName">
<tr>
<td>Institution Name *</td>
<td><html:text property="institutionName" size="100" />
<font color=red>
<html:errors property="institutionName" />
</font>
....

The struts-config.xmls looks like

<message-resources parameter="resources" null="false"/>

<action
path="/addInstitution"
type="package.AddInstitutionAction"
name="addInstitution"
scope="session"
input="/addInstitution.jsp">


I dont have <html:errors/> tag anywhere on the jsp. This displays the
ActionError msgs twice - Once in a red font and the second ones appear
on the top of the page.

I was wondering if there is a way to display the ActionErrors for a
property right next to the field. Any help will be appreciated!

Thanks,
Beena
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top