-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestPage1.html
186 lines (156 loc) · 7.67 KB
/
testPage1.html
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Basic Page Needs -->
<meta charset="utf-8">
<title>{{page.title}}</title>
<meta name="description" content="">
<meta name="author" content="Kevin Holloway">
<!-- Mobile Specific Metas -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Fonts -->
<!-- Raleway font for page titles and section headers -->
<link href='https://fonts.googleapis.com/css?family=Raleway:300,400,700' rel='stylesheet' type='text/css'>
<!-- Inconsolata font for code examples -->
<link href='https://fonts.googleapis.com/css?family=Inconsolata:400,700' rel='stylesheet' type='text/css'>
<!-- Homepage CSS -->
<link rel="stylesheet" href="css/normalize.css" type="text/css">
<link rel="stylesheet" href="css/skeleton.css" type="text/css">
<link rel="stylesheet" href="css/special.css" type="text/css">
<link rel="stylesheet" href="css/syntax.css" type="text/css">
<!-- Favicon
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="icon" type="image/png" href="/images/favicon.png">
</head>
</head>
<body>
<div class="site">
<div id="title">
<span class="desc">j</span><span class="rest">2form</span>
</div>
<div id="navbar">
<ul>
<li><span class="here">home</span></li><wbr><!--
--><li><a href="/blog">blog</a></li><wbr><!--
--><li><a href="/downloads">downloads</a></li><wbr><!--
--><li><a href="/documentation">documentation</a></li><wbr><!--
--><li><a href="/javadoc">javadoc api</a></li><wbr><!--
--><li><a href="/about">about</a></li>
</ul>
</div>
<h1>j2form</h1>
<p>j2form takes an ordinary Java class and produces a data entry form. The form handles all the data entry validation, including inter-field validation. The form handles all the Java types you would expect, such as:</p>
<ul>
<li>Strings</li>
<li>Integers</li>
<li>Floating point and decimal numbers</li>
<li>Booleans</li>
<li>Enumerated types</li>
<li>Dates</li>
<li>URL’s</li>
<li>File and directory names</li>
</ul>
<p>j2form also handles custom types, lists and arrays, embedded classes, references to other classes, and interfaces.</p>
<p>Default values are supported. They can be specified as initial field values, or calculated at runtime.</p>
<p>A very simple example is:</p>
<pre><code>public class Invoice {
private Date purchaseDate = new Date();
private Double amount;
private String paymentCardNumber;
private boolean gstApplicable;
public Date getPurchaseDate() {
return purchaseDate;
}
public Double getAmount() {
return amount;
}
public String getPaymentCardNumber() {
return paymentCardNumber;
}
public boolean getGstApplicable();
return getApplicable;
}
}</code></pre>
<p>With j2form, the following data entry form is produced:</p>
<p>[image of Invoice.java data entry form]</p>
<p>The <strong>Purchase date</strong> field shows the default value of “today”. This is from the code <code>= new Date()</code>.</p>
<p><a href="annotations" title="the full list of form annotations">Annotations are available</a> to enhance the data entry form. One of these is the <a href="formFieldAnnotation" title="more information on the @FormField annotation">@FormField</a>. The @FormField annotation specifies:</p>
<ul>
<li>A field length and regular expression pattern for Strings.</li>
<li>The allowed sign and number of whole and decimal digits for Double, Float and other decimal types.</li>
<li>The minimum and maximum for integer types.</li>
<li>Other more advanced options.</li>
</ul>
<p>A second example that includes @FormField annotations and a list.</p>
<div class="highlight"><pre><code class="language-java" data-lang="java"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Item</span> <span class="o">{</span>
<span class="nd">@FormField</span><span class="o">(</span><span class="n">length</span><span class="o">=</span><span class="mi">6</span><span class="o">)</span>
<span class="kd">private</span> <span class="n">String</span> <span class="n">itemNumber</span><span class="o">;</span>
<span class="kd">private</span> <span class="kt">double</span> <span class="n">cost</span><span class="o">;</span>
<span class="nd">@FormField</span><span class="o">(</span><span class="n">min</span><span class="o">=</span><span class="mi">0</span><span class="o">,</span> <span class="n">max</span><span class="o">=</span><span class="mi">999</span><span class="o">)</span>
<span class="kd">private</span> <span class="kt">int</span> <span class="n">quantity</span><span class="o">;</span>
<span class="o">...</span> <span class="n">getter</span> <span class="n">methods</span>
<span class="o">}</span></code></pre></div>
<pre><code>public class Invoice {
private Date purchaseDate = new Date();
@FormField(sign=
private Double amount;
@FormField(regex="^[0-9 ]$", message="Only digits and spaces are allowed")
private String paymentCardNumber;
private boolean gstApplicable;
private List<Item> itemsPurchased;
... getter methods
private void checkCardDigits () throws UserEntryException {
int n = 0;
for (int i = 0; i < paymentCardNumber.length(); i++) {
char c = paymentCardNumber.charAt(i);
if (Character.isDigit(c)) {
n++;
}
}
if (n < 16) {
throw new UserEntryException("16 digits are required", INCOMPLETE);
} else if (n > 16) {
throw new UserEntryException("only 16 digits are required", ERROR);
}
}
}
</code></pre>
<p><a href="customTypes.textile" title="more information on custom types">Custom types</a> can also be used.</p>
<p>Note the validation method <strong>checkCardDigits</strong>. j2form can determine that this method is depend on <strong>paymentCardNumber</strong>, and will call this method whenever <strong>paymentCardNumber</strong> changes. The user will see and incomplete icon if the number of digits is less than 16, and will see an error icon if the number of digits is greater than 16. See <a href="validation.textile" title="more information on validation">Validation</a> for how j2form validates user entry, and how validation methods are called.</p>
<div class="footer">
<div class="contact">
<p>
Kevin Holloway [[email protected]]
</p>
</div>
<div class="contact">
<p>
<a href="http://github.com/kevinau">Source code on GitHub</a>
</p>
</div>
<!-- When a RSS feed is established, uncomment this div
<div class="rss">
<a href="http://feeds.feedburner.com/tom-preston-werner">
<img src="/images/rss.png" alt="Subscribe to RSS Feed" />
</a>
</div>
-->
</div>
</div>
<!-- Do I really want this link?
<a href="http://github.com/kevinau"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub" /></a>
-->
<!-- Google Analytics -->
<!-- Change when Google Analytics is set up
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-6016902-1");
pageTracker._trackPageview();
</script>
-->
<!-- Google Analytics end -->
</body>
</html>