File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Regular expression validation problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Regular expression validation problem" Watch "Regular expression validation problem" New topic

Regular expression validation problem

Mikael Gyth

Joined: Sep 30, 2012
Posts: 7

I'm stuck trying to validate a String field in a entity class.

The regular expression should work, but every time I attempt to insert a word with æ,ø or å, Æ, Ø orÅ in it it fails validation.

Does anyone have any tips or hints on what's wrong?

Mikael Gyth

Joined: Sep 30, 2012
Posts: 7
Apparantly they aren't getting trough the validation because the server reads them as ÆØÅ characters. I have gone trough all my files and my database to make sure it's all UFT-8. But i'm still getting the same results.
Anyone know if there are any additional charset settings I have to set anywhere?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

I think that you may be having issues in using extended character codes in your Pattern. That would be independent of whether you have the other settings correct or not.

There are a couple of possibilities:

1. Specify the pattern characters as Unicode escapes

2. Define the pattern using I18N rules

3. See if your underlying JVM Locale settings can be set to accept these characters as normal letters

4. Write tour own custom string validator

An IDE is no substitute for an Intelligent Developer.
Mikael Gyth

Joined: Sep 30, 2012
Posts: 7
Hello and thanks for the reply.
These characters have worked before, we had the same problem early in the project but it has come back at some point, and we probably didn't notice it until the validation failed.
I think the most relevant solution would be nr. 3. But as I said earlier I have gone trough all the tables in the database and all the xhtml files and made sure they are all UTF-8, witch to my knowledge should be sufficient to make this work.
Is there anywhere else in the project config files or on the Glassfish server we can set these parameters? we have a Maven web project with JSF and PrimeFaces, also we are using hibernate(eclipselink) for out datasource.
I agree. Here's the link:
subject: Regular expression validation problem
It's not a secret anymore!