Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » User custom method in EL?
User custom method in EL? [message #1268331] Mon, 10 March 2014 11:16 Go to next message
Hazem ELRAFFIEE is currently offline Hazem ELRAFFIEEFriend
Messages: 61
Registered: September 2012
Member
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 12:56 Go to previous messageGo to next message
Greg Amerson is currently offline Greg AmersonFriend
Messages: 119
Registered: March 2010
Senior Member
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 13:06 Go to previous messageGo to next message
Hazem ELRAFFIEE is currently offline Hazem ELRAFFIEEFriend
Messages: 61
Registered: September 2012
Member
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 13:13 Go to previous messageGo to next message
Greg Amerson is currently offline Greg AmersonFriend
Messages: 119
Registered: March 2010
Senior Member
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 13:13]

Report message to a moderator

Re: User custom method in EL? [message #1268460 is a reply to message #1268405] Mon, 10 March 2014 14:22 Go to previous message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
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: Tue Mar 19 11:55:01 GMT 2024

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

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

Back to the top