help required

304 views
Skip to first unread message

poonam

unread,
May 18, 2009, 9:10:28 AM5/18/09
to Google Web Toolkit
Hello,
I have developed an Validation application.And in that having
different classes for Numeric Field, Alphabetic Field, Pattern
Matching, etc.
But when I import -
import java.util.regex.Matcher;
import java.util.regex.Pattern;
I get errors as -
The import java.util.regex cannot be resolved
but,Pattern Matching is the requirement of the classes,
I have send the class and detailed error message below.Please help or
suggest what can I do?
-----class -----
public class NumericField implements Validation {
public boolean validate() {

if(widgetToValidate.getText()!= "[0-9]") {
GWT.log("in validate() of RequiredField ",null);

String regex = "[0-9]";
Pattern p = Pattern.compile(regex,Pattern.CASE_INSENSITIVE);
Matcher matcher = p.matcher(regex);
//boolean b = m.matches();

if(matcher.find())
{
Window.alert("correct format");
}
return false;
}
return true;

}
}

When I compile this program I get the errors below :

D:\Validation>StudentInfo-compile
Analyzing source in module 'com.company.StudentInfo'
[ERROR] Errors in 'D:\Validation\src\com\company\client
\Alpahabetic.java'
[ERROR] Line 8: The import java.util.regex cannot be resolved
[ERROR] Line 131: PatternSyntaxException cannot be resolved to
a type
[ERROR] Line 132: ex cannot be resolved
[ERROR] Errors in 'D:\Validation\src\com\company\client
\NumericField.java'
[ERROR] Line 5: The import java.util.regex cannot be resolved
[ERROR] Line 6: The import java.util.regex cannot be resolved
[ERROR] Line 73: Pattern.CASE_INSENSITIVE cannot be resolved
[ERROR] Line 74: Matcher cannot be resolved to a type
[ERROR] Line 74: The method matcher(String) is undefined for
the type Pattern
Finding entry point classes
[ERROR] Unable to find type 'com.company.client.StudentInfo'
[ERROR] Hint: Previous compiler errors may have made this type
unavailable
[ERROR] Hint: Check the inheritance chain from your module; it
may not be inheriting a required module or a module
may not be adding its source path entries properly
[ERROR] Build failed

Thus, I am not able to solve the error : The import java.util.regex
cannot be resolved

How to solve it?
Thanks.

Mathieu BONIFACE

unread,
May 18, 2009, 9:13:39 AM5/18/09
to Google-We...@googlegroups.com
Hi,

GWT does not emule the java.util.regex class

You should see http://code.google.com/intl/fr/webtoolkit/doc/1.6/RefJreEmulation.html#Package_java_util
for more informations.

Mathieu Boniface

2009/5/18 poonam <poon...@gmail.com>

Salvador Diaz

unread,
May 18, 2009, 9:22:21 AM5/18/09
to Google Web Toolkit
How about reading the documentation?

http://code.google.com/intl/fr/webtoolkit/doc/1.6/DevGuideCodingBasics.html#DevGuideClientSide

The very first paragraph has the answer to your problem and instructs
you to read the following part:
http://code.google.com/intl/fr/webtoolkit/doc/1.6/DevGuideCodingBasics.html#DevGuideJavaCompatibility

And ultimately this should precisely answer your question:
http://code.google.com/webtoolkit/doc/1.6/RefJreEmulation.html

=>There is no java.util.regex support in client-side code. You should
use instead:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#matches(java.lang.String)

If there's anything there that's not clear enough, feel free to ask
for clarifications.

Salvador
Reply all
Reply to author
Forward
0 new messages