• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Validate() method of ActionForm

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anybody please help ? I am using WebSphere 4.0 Application server.
I am using the validate() method for client side validation. I am getting redirected to the input Page after validation errors. But the Error Messages which are coded in ApplicationResoureces.properties not shown in the page
JSP PAGE
<%@ page language= "java" session="true" %>
<%@ taglib uri="/WEB-INF/lib/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/lib/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/lib/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/lib/struts-validator.tld" prefix="validator" %>
<html>
<head>
<title></title>
</head>
<body bgcolor="#E2E2E2">
<html:errors/>
<font face="Trebuchet MS" size=1>
<html:form action="/change_password">
<br><br><h4><b>                        
            CHANGE AUTHENICATION PASSWORD</b></h4><br><br>
<html:hidden property="userId" value='<%=(String)session.getAttribute("userId")%>'/>
<table border="0" width="50%" height="127" cellspacing="1">
<tr>
<td width="50%" height="26" align="right">User</td>
<td width="50%" height="26" align="left">
<input type="text" name="userName" size="20" value='<%=(String)session.getAttribute("userName")%>' style="background-color: #C0C0C0" readonly="true">
</td>
</tr>
<tr>
<td width="50%" height="26" align="right">Old password</td>
<td width="50%" height="26" align="left">
<html assword property="oldpwd" size="12" maxlength="8"/>
</td>
</tr>
<tr>
<td width="50%" height="26" align="right">New password</td>
<td width="50%" height="26" align="left">
<html assword property="newpwd" size='12' maxlength='8'/>
</td>
</tr>
<tr>
<td width="50%" height="26" align="right">Re-type new password</td>
<td width="508%" height="26" align="left">
<html assword property="rnewpwd" size="12" maxlength="8"/>
</td>
</tr>
<tr>
<td colspan="2" height="26"align="center">
</td>
</tr>
<tr>
<td colspan="2" height="26" align="center">
<html:submit property = "change" value="Change Password"/>
<html:reset value="Reset"/>
</td>
</table>
</font>

</html:form>
</body>
</html>
Validate method
public ActionErrors validate(ActionMapping amapping, HttpServletRequest request)
{
ActionErrors errors=new ActionErrors();
if ((oldpwd==null) || (oldpwd.length() != 8))
errors.add("oldpwd", new ActionError("error.changepwd.oldpwd"));
if ((newpwd==null) || (newpwd.length() != 8))
errors.add("newpwd", new ActionError("error.changepwd.newpwd"));
if ((rnewpwd==null) || (rnewpwd.length() != 8))
errors.add("rnewpwd", new ActionError("error.changepwd.rnewpwd"));
if (!newpwd.equals(rnewpwd))
errors.add("notmatch", new ActionError("error.changepwd.notmatch"));
return errors;
}
ApplicationResources.properties
errors.header=<h3>Errors :</h3><UL>
errors.footer=</UL><hr>
error.changepwd.oldpwd=<li>Old password length is invalid</li>
error.changepwd.newpwd=<li>New password length is invalid</li>
error.changepwd.rnewpwd=<li>Retyped new password length is invalid</li>
error.changepwd.notmatch=<li>New password and Re-typed new password do not match</li>
[ July 02, 2003: Message edited by: Manu Ramakrishnan ]
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First thing for your info, this is a server side validation. Client side validation can only be done via Javascript.
To show your error messages add the following code to your page,e.g.
<html:errors property="changepwd.oldpwd"/>
On this location the error message now appears
Olli
 
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic