Skip to main content



      Home
Home » Archived » Sapphire » User custom method in EL?
User custom method in EL? [message #1268331] Mon, 10 March 2014 07:16 Go to next message
Eclipse UserFriend
Hello

Is there anything I can do to use user custom method in @Validation EL ?

I mean something like:
@Validation
(
    rule = "${ MyToolBox.isValidName(Name) }",
    message = "Illegal Name!!"
)


Is the only way to achieve that is to create a custom ValidationService?

What if I have like 5 validations inside a @Validations annotation, and would like to add a Validation which depends on a custom complex function, should I remove all the 5 validations and re-create them from scratch in the new Validation Service? or is @Service and @Validation work together without problems?

Thank you in advance Smile
Re: User custom method in EL? [message #1268394 is a reply to message #1268331] Mon, 10 March 2014 08:56 Go to previous messageGo to next message
Eclipse UserFriend
I believe you can add custom EL functions using sapphire-extension.xml. But I have never personally used that feature. Would custom EL functions do what you need?
Re: User custom method in EL? [message #1268401 is a reply to message #1268394] Mon, 10 March 2014 09:06 Go to previous messageGo to next message
Eclipse UserFriend
Would you please explain a little more Smile ?

What is sapphire-extension.xml? and where can I find it? and what should I refer to?
Re: User custom method in EL? [message #1268405 is a reply to message #1268401] Mon, 10 March 2014 09:13 Go to previous messageGo to next message
Eclipse UserFriend
Do you have the sapphire samples project loaded into your workspace? If you don't I would highly recommend you download it or check it out from git as its really useful. http://git.eclipse.org/c/sapphire/org.eclipse.sapphire.git/tree/plugins/org.eclipse.sapphire.samples

Once you have that downloaded you can see that your 2 use-cases (custom EL function and StringToPOJO and POJOtoStringConversionService) are shown in there with examples in this file:
org.eclipse.sapphire.samples/META-INF/sapphire-extension.xml

http://git.eclipse.org/c/sapphire/org.eclipse.sapphire.git/tree/plugins/org.eclipse.sapphire.samples/META-INF/sapphire-extension.xml

[Updated on: Mon, 10 March 2014 09:13] by Moderator

Re: User custom method in EL? [message #1268460 is a reply to message #1268405] Mon, 10 March 2014 10:22 Go to previous message
Eclipse UserFriend
Quote:
What if I have like 5 validations inside a @Validations annotation, and would like to add a Validation which depends on a custom complex function, should I remove all the 5 validations and re-create them from scratch in the new Validation Service? or is @Service and @Validation work together without problems?


You can mix-n-match any number of ValidationService implementations and @Validation annotations. They will work together without problems.

A ValidationService would probably be easier than a custom EL function for a usecase like "${ MyToolBox.isValidName(Name) }". The advantage of a function is that it is composable and re-usable across a variety of usecases, not limited to validation.
Previous Topic:Announcing Sapphire 0.7.1 Release
Next Topic:Property Custom Parser?
Goto Forum:
  


Current Time: Mon May 05 07:54:47 EDT 2025

Powered by FUDForum. Page generated in 0.03897 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top