|
Tomahawk Tags |
|
If we enter wrong email id then the message
written is message tag is displayed like is the
figure below:
5-Tomahawk validateRegExpr tag
This tag is used to validate a string entered
by the user. If we want the user to enter a
specific pattern of string then we can set the
pattern for that component For example, we
have an input field and we want the user to
enter a number that consists of any number
with “1” in the beginning but only one “2” at
the last. So for this, Tomahawk provides a tag
validateRegExpr, which has “pattern” attribute
that is used to specify the pattern to be followed
by the user while inputting the string in the
box. If the entered string is not following the
pattern then a message can be displayed using “message” attribute.
Code Description:
<%@ taglib uri=”http://java.sun.com/jsf/
html” prefix=”h”%>
<%@ taglib uri=”http://java.sun.com/jsf/
core” prefix=”f”%>
<%@ taglib uri=”http://myfaces.apache.org/
tomahawk” prefix=”t”%>
<f:view>
<html>
<head>
<meta http-equiv=”Content-Type”
content=”text/html; charset=iso-8859-1">
<title>t:validateRegExpr example</title>
<style type=”text/css”> |
|
<!—
body{
background-color:#fff2f2;
margin-top:30;
}
—>
</style>
</head>
<body >
<h:form>
<t:outputText value=”Enter any number
starting from any number of ‘1’s but ‘2’ at
last. “/></p>
<t:inputTextHelp id=”regExprValue”
helpText=”Like :12, 112, 11112"
required=”true”>
<t:validateRegExpr pattern=”1*2"
message=”Type correct Number.”/>
</t:inputTextHelp>
<t:message for=”regExprValue”/></p>
<t:commandButton id=”cb” image=”images/
submit_button.gif” action=”welcome”/>
</h:form>
</body>
</html>
</f:view>
Rendered Output:
This is the output of the above code:
|
|
Oct 2007 | Java Jazz Up |38 |
|
|
|
Pages:
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53 ,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63 ,
64,
65 ,
66 ,
67 ,
68 ,
69 ,
70,
71,
72,
73,
74,
75,
76,
77,
78,
Download PDF |
|
|
|
|
|
|
|
|
|