|
EchoPoint API - 3.0.0b5 App Webcontainer |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnextapp.echo.app.Component
nextapp.echo.app.text.TextComponent
nextapp.echo.app.TextField
echopoint.internal.TextField
echopoint.RegexTextField
public class RegexTextField
A text field that enforces a user supplied regular expression on a key press. Allows creation of serial number field, character only field etc.
The following shows sample use of this class.
import nextapp.echo.app.TextField;
import echopoint.RegexTextField;
...
// Create a field that allow real numbers with two digit fractional part
final TextField tf = new RegexTextField( "^[\\d]+[.]{0,1}[\\d]{1,2}$" );
Note: It is recommended that you test the regular expression using a simple test html page in your browser of choice before you set it for the component. This is to ensure that the expression you specify is valid and behaves the way you want it to work.
<html>
<head>
<title>RegExp Test</title>
<script type='text/javascript'>
function check( event )
{
event = (event) ? event : window.event;
var charCode = (event.which) ? event.which : event.keyCode;
var status = true;
if ( charCode <= 31 )
{
status = true;
return status;
}
var regexString = "^[A-Z]{1,1}[a-z]*$";
var regex = new RegExp( regexString );
var input = document.getElementById( 'textField' );
var value = input.value + String.fromCharCode( charCode );
status = regex.test( value );
return status;
}
</script>
</head>
<body>
<input id='textField' type='text' onkeypress='return check(event)' />
</body>
</html>
| Field Summary | |
|---|---|
static String |
PROPERTY_REGEX
The regular expression to specify. |
| Fields inherited from class echopoint.internal.TextField |
|---|
PROPERTY_DEFAULT_TEXT |
| Constructor Summary | |
|---|---|
RegexTextField()
Default constructor. |
|
RegexTextField(String regex)
Create a new text field with the specified regex pattern. |
|
| Method Summary | |
|---|---|
String |
getRegex()
Return the regular expression in use for the field ( PROPERTY_REGEX). |
void |
setRegex(String regex)
Set the regular expression pattern ( PROPERTY_REGEX) to use to
restrict input into this * field. |
| Methods inherited from class echopoint.internal.TextField |
|---|
getDefaultText, setDefaultText |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String PROPERTY_REGEX
RegExp JavaScript object and hence the expression
must be escaped as you would when compiling a Java regex pattern.
This property may also be styled.
| Constructor Detail |
|---|
public RegexTextField()
public RegexTextField(String regex)
regex - The regular expression to use.| Method Detail |
|---|
public String getRegex()
PROPERTY_REGEX).
public void setRegex(String regex)
PROPERTY_REGEX) to use to
restrict input into this * field. This value may also be styled.
regex - The regular expression to use.
|
EchoPoint API - 3.0.0b5 App Webcontainer |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||