-->
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.  [ 9 posts ] 
Author Message
 Post subject: expression language integration
PostPosted: Fri Mar 28, 2008 6:46 pm 
Newbie

Joined: Fri Mar 28, 2008 6:40 pm
Posts: 1
Hi Everybody

I just read about the start of the feedback cycle of JSR 303.

Here is my first suggestion:

We are corrently using OVal - ("the object validation framework for Java™ 5 or later") (http://oval.sourceforge.net/).
Beside similar annotations to JSR303's, it implements the nice feature to integrate with several expression languages,
allowing you to specify more extensive object validation.

It would be nice if a similar mechanism was specified in JSR303, so there is a lesser need to implement custom validators.
What do you think?

Regards
Peter


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 29, 2008 11:03 am 
Newbie

Joined: Tue Dec 04, 2007 2:48 pm
Posts: 6
Where you talking about the @Assert annotation of the OVal?

I would like to to this:

Code:
public interface CustomConstraint implements Constraint<MyCustomValidation> {

  @Javascript(file = "somefile.js", function = "validateCustom")
  public boolean isValid(Object value);

}


or if you need some extra java functionality

Code:
public class CustomConstraint implements Constraint<MyCustomValidation>, StandardConstraint {

  @Javascript(file = "somefile.js", function = "validateCustom")
  public boolean isValid(Object value) {}

  public StandardConstraintDescriptor getStandardConstraints() {
    return new StandardConstraintDescriptor() { ... };
  }
}


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 30, 2008 7:16 am 
Newbie

Joined: Sun Mar 30, 2008 7:09 am
Posts: 3
Location: The Ether
You can already do both of those things. JSR-303 provides a framework for creating reusable validation annotations.

All you need is a class that implements Constraint<T>.

Then declare your own annotation to do whatever you like:

Code:
@ValidatorClass(MyELValidator.class)
@Retention(RUNTIME)
public @interface EL {
     String value();
}


then use it anywhere:

Code:
@EL(" age > 13 ")
public class Address {
    private int age;
    ...
}

_________________
Dhanji R. Prasanna
JSR-303 Expert Group member

Fee Fi Fo Fum, do you smell Dependency Injection?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 01, 2008 11:23 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
We always had in the radar the idea of reusing the unified expression language. I don't know it's status atm though.

barbacena, your approach is interesting but it makes things a bit dangerous, doesn't it? What if someone change the js method without the standard description?
Do you have usecases where you see your approach useful?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 01, 2008 12:20 pm 
Newbie

Joined: Tue Dec 04, 2007 2:48 pm
Posts: 6
Hi Emmanuel,

It is useful to do client side validation at Seam/JSF projects. Today, what we do is replicate the hibernate validation on javascript and use jQuery validation to validate on client side. But this violates DRY.

What I really would like is to do everything in java, but than we would need a Java to Javascript compiler (as GWT) to do the client side.

The way a propose we would do the validation in js and a JSF component would plug the js on client side.

Got it?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 6:30 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I got it
But I don't think this is the right approach.
GWT is the easy path as soon as they support Java 5
The other approach is the StandarConstraint solution described in the spec.
The idea is to have JSF or the JSF components like richFaces to go read the constraints and apply them as best as they can.

The end result is the same though, no duplication for the user. Pointing to a javascript file doesn't seem appealing to me.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 10, 2008 10:25 pm 
Beginner
Beginner

Joined: Fri Nov 03, 2006 3:21 pm
Posts: 30
The OVal has a feature similar to what I had suggested (and created patch to HV) in this topic:

http://forum.hibernate.org/viewtopic.php?t=979555

I don't know the OVal, it seems a good framework =)
EL support is extremely useful for complex cases.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 11, 2008 1:16 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
conditional validation is a different topic.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 11, 2008 2:09 pm 
Beginner
Beginner

Joined: Fri Nov 03, 2006 3:21 pm
Posts: 30
yes... We all know that.
But EL (this topic subject) is part of conditional validation.

Sorry Emmanuel, HV is a good framework also =)
I use HV and help people to use it using my project: http://www.j2eespider.org
http://www.infoq.com/news/2008/03/J2EE-Spider

I really like the HV.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.