-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Validator annotation
PostPosted: Tue Apr 03, 2007 10:12 am 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
Hi,
Is there any Validator annotation that will check the scale of a Float or BigDecimal java type? Does Hibernate have the concept of scale at all?
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 4:27 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@Digits

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 08, 2008 8:09 pm 
I am using @Digits now on a JPA entity. This is a Seam2.0.0.GA app on JBoss4.2.1.GA.

The following xhtml snippet works properly with @Length on the getter method in the entity:

Code:
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                     

                     
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:a4j="http://richfaces.org/a4j"
   xmlns:rich="http://richfaces.org/rich"
   xmlns:s="http://jboss.com/products/seam/taglib"
   template="layout/template.xhtml">
   
<ui:define name="body">
                
         <h:form>
            barcode:
            <h:inputText value="#{tbHardware.coxBarcode}" required="true">
               <s:validate/>
            </h:inputText>
         <h:commandButton value="submit"/>
         </h:form>
         
         <h:messages globalOnly="false" styleClass="message"/>
            
            
</ui:define>

</ui:composition>   


The @Digits validator does not work properly (e.g. if I enter "efg" in the inputText, I should see the err msg in h:messages component).

entity:

Code:
@Entity
@Table(name = "tbHardware")
@Name("tbHardware")
public class TbHardware implements java.io.Serializable {

...

@Column(name = "CoxBarcode", nullable = false, length = 200)
   //AS 05-08-08 - moving some validations for barcode here from SFSB processValueChange()...
   @Length(max=5, min=5, message="INVALID FORMAT - PLEASE ENTER A NUMERIC BARCODE (EX: 01234)")
   @Digits(integerDigits=5, message="PERMITTED BARCODE LENGTH MUST BE 5")   
   public String getCoxBarcode() {
      return this.coxBarcode;
   }

   public void setCoxBarcode(String coxBarcode) {
      this.coxBarcode = coxBarcode;
   }
...
}


what's the problem here or is this a bug? There's nothing interesting in the server.log (i.e. no errors). thx.


Top
  
 
 Post subject:
PostPosted: Tue Jun 03, 2008 3:52 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I've added a test to add non numeric string to Digits and it works as expected. which version of HV are you using?

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.