java - How to dynamically set value of mask option of @Validate annotation -


here's code:

somefile.properties

string.regex="someregex" 

someactionclass.java

@value("${string.regex}") private string regex="";  @validate(mask = regex) private string stringtovalidate; 

the file somefile.properties loaded on server startup , value "someregex" stored somewhere in session, available.

the problem mask requires constant value, , if put final @ regex="" cannot overwrite init value string.regex one; on other hand if put final not initialize variable, java compiler complain it.

is there way use mask option value retrieved file not know?

is possible directly on jsp in smart way, since i've have several fields validate , not want perform check , write message error each one?

annotation value can changed @ runtime using reflection.

please take @ (see post marked answer)

modify class definition's annotation string parameter @ runtime

be careful approach, of caveats of described. also, being able chenge value @ runtime, retention policy annotation has runtime

it's not solution particular question, has useful information on how ti perform operation on annotations.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -