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
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