validation - Grails Duplicate Error Messages -


I am new to grails and I have a problem:

I have a snippet of GSP :

  & lt; G: form url = "[administrator: 'main', verb: 'login']" & gt; & Lt; Label = "name" & gt; Usuario: & lt; / Label & gt; & Lt; Br / & gt; & Lt; Input type = "text" name = "name" /> gt; & Lt; Br / & gt; & Lt; = "Pass" for label & gt; Password: & lt; / Label & gt; & Lt; Br / & gt; & Lt; Input type = "password" name = "password" /> & Lt; Br / & gt; & Lt; Input type = "submit" value = "login" /> gt; & Lt; Br / & gt; & Lt; G: RenderErayer Bean = "$ {cmd}" /> & Lt; / G: form & gt; The administrator uses a command object, here is the code for both:  
  DRAF login = {login-in command CMD - & gt; If the (string: string) constraint = {string (string: 'index', model: [cmi: cmd])}} class loginCommand {string name string passwords = { Name (empty: incorrect, size: 5..10) password (empty: wrong, size: 5..10)}}  

The problem is that when I enter an incorrect name or Pass (outside or out of range) This shows me 4 errors, two for password and two for user . They are identical, but have been repeated.

I found that a method "bool validateCommand () {name & password}" to make and command it to place. Validate () does not throw duplicates, but I want to use the obstacles of Grails to keep dry things

Any ideas why this happens? Thanks a lot!

When you take command objects in controller actions, Grails executes validate () automatically < / Code>, so there is no need to call it manually

  if instead of (cmd.hasErrors ())  

Try
  (cmd.validate ())  

It looks like recognizes () new in command object (duplicate) ) The error adds IMHO should not happen and probably there is a bug in Grails. You should consider this problem.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -