aspose file tools*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Regular expression validation problem" Watch "Regular expression validation problem" New topic
Author

Regular expression validation problem

Mikael Gyth
Greenhorn

Joined: Sep 30, 2012
Posts: 7
Hello.

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?

Br.
Mikael Gyth
Greenhorn

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: 15661
    
  15

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


Customer surveys are for companies who didn't pay proper attention to begin with.
Mikael Gyth
Greenhorn

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: http://aspose.com/file-tools
 
subject: Regular expression validation problem
 
Similar Threads
Regular Expression for EMail Validation
Checking for java special characters in a string
how to split string using . operator
String replacement
List to String