struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lesaint Sébastien <lesa...@ginlex.com>
Subject RE: Help with validate ActionForm method
Date Mon, 14 Jun 2004 09:51:13 GMT
Hi Satish,

Problem is not related to validate="true" set on two actions, I've only one
in my whole struts-confif.xml file.

Any other idea?

-- 
Seb'

-----Message d'origine-----
De : Satish Kataria [mailto:skataria@sapient.com] 
Envoyé : lundi 14 juin 2004 10:09
À : Struts Users Mailing List; Lesaint Sébastien
Objet : RE: Help with validate ActionForm method

I hope you have not set validate="true" for the both the load and submit
action mapping
i.e there wld be a action mapping for loading the screen(say load) The
validate attribute for this action
Be set to false

Then there wld be a action maqpping when to want to validate(say on submit
of a button - lets call it submitaction). The validate attribute of only
this shld be set to true

Thanks,
Satish


-----Original Message-----
From: Lesaint Sébastien [mailto:lesaint@ginlex.com] 
Sent: Monday, June 14, 2004 1:19 PM
To: Struts Users Mailing List
Subject: Help with validate ActionForm method


Hi,

I'm using ActionForm for one of my pages and I implemented the validate
method as follow: public ActionErrors validate(ActionMapping mapping,
                               HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();

    if (isFieldEmpty(login)) {
      errors.add("login", new ActionError("loginForm.login.required"));
    }

    if (isFieldEmpty(password)) {
      errors.add("password", new
ActionError("loginForm.password.required"));
    }

    if (errors.isEmpty()) {
      if (!isConnected(login, password)) {
        errors.add("login", new
ActionError("loginForm.msgs.wrongLoginorPassword"));
      }
    }

    if (!errors.isEmpty()) {
      getLogger().info(this, "Failed attempt to log in : [" + login + "/" +
password + "] from : " + request.getRemoteHost());
    }
    return (errors);
 }

You can see that I log each time someone fail to log in.
When the validate method returns an empty Error Array, login/password are
checked in an Action object.

The problem is that I have the following trace in the log when somebody
successfully log in : 09:26:54,500 INFO  [lex.LoginAction] User logged in
[login/pwd] sessionId [773BB4634682A159DC680847073E4EC8] from [10.10.10.10]
09:26:54,587 INFO  [lex.LoginActionForm] Failed attempt to log in : [/] from
: 10.10.10.10

These traces obiviously means that the validate method is called twice, the
second time the ActionForm having empty fields.

Does anybody know why such a thing would happen ????

Thanks

-- 
Seb'

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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message