Announcement Announcement Module
Collapse
No announcement yet.
custom validation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • custom validation

    hi, i'm pretty new in roo and have some trouble with validation. Here my test project:

    Code:
    project --topLevelPackage org.dischi --projectName dischi
    jpa setup --database MYSQL --provider HIBERNATE 
    entity jpa --class ~.model.Album --testAutomatically 
    field string --fieldName autore --notNull 
    field string --fieldName titolo --notNull 
    field number --fieldName anno --type int
    field number --fieldName prezzo --type float
    web mvc setup
    web mvc scaffold --class ~.web.AlbumController --backingType ~.model.Album
    the modified Album model

    Code:
    ...
    @RooJavaBean
    @RooToString
    @RooJpaActiveRecord
    public class Album {
    
        @NotNull
        private String autore;
    
        @NotNull
        private String titolo;
    
        private int anno;
    
        private float prezzo;
        
        @AssertTrue(message = "invalid year.")
        public boolean isAnnoValid() {
        	if ((anno >1999) && (anno < 2021) )
        		return true;
        	else
        		return false;    	
        }
    }
    the model is validated but the message ("invalid year") does not appear.
    where am i wrong?
    Thanks in advance
Working...
X