Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8922835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:56:51+00:00 2026-06-15T06:56:51+00:00

I am using org.hibernate.validator.Pattern annotation in my jsf managed bean to validate an <h:inputText>

  • 0

I am using org.hibernate.validator.Pattern annotation in my jsf managed bean to validate an <h:inputText> component.

@Pattern(regex="\\W+")
public String getText() {
  return text;
}

My question is, is there a way to get the regular expression from a method or EL withought hard-coding it.
For an example

@Pattern(regex = getRexEx())

OR

@Pattern(regex = "#{bean.regEx}")

I googled and found that the regEx should be a constant. However there can be a alternative way to accomplish this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:56:52+00:00Added an answer on June 15, 2026 at 6:56 am

    The arguments to an annotation need to be compile time constants, so no, it’s not possible to specify a run time expression as the argument for @Pattern. It’s also not possible to pass an EL expression as argument and have it do anything because, well, that’s simply not how the pattern validator was written.

    What you can do however, is define your own a validator class that takes a form of an EL expression and validates the bean property against it. Good luck with the context management for that though! Not a simple task.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using org.apache.commons.validator.routines.DateValidator to validate a date with a simple date pattern dd/mm/yyyy
I am using @NotEmpty annotation from Hibernate validator. However I am required to provide
I'm using Hibernate validator and trying to create a little util class: public class
I am using hibernate validator to validate a form. However the validator does not
When using hibernate to retrieve data from Oracle 11g DB using either org.hibernate.dialect.Oracle10gDialect or
I am using htmlparser (htmlparser.org) to re-write all the link's in a input String.
I'm using Hibernate Validator in an application with EJB and Spring MVC. I'm using
i'm trying to validate a new bean object using the jpa validation. I'm getting
I'm using spring based validation in combination with hibernate validator enabled by the following
i am using hibernate validation (4.2.0 Final) with JSF 2 and Spring and here's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.