Java Reference
In-Depth Information
2. In the Open Project dialog, navigate to:
tut-install
/examples/web/
3. Select the
ajaxguessnumber
folder
.
4. Select the Open as Main Project check box.
5. Click Open Project.
6. In the Projects tab, right-click the
ajaxguessnumber
project and select
Deploy.
To Build, Package, and Deploy the
ajaxguessnumber
Example Using Ant
1. In a terminal window, go to:
tut-install
/examples/web/ajaxguessnumber/
2. Type the following command:
ant
This command calls the
default
target, which builds and packages the applica-
tion into a WAR file,
ajaxguessnumber.war
, located in the
dist
directory.
3. Type the following command:
ant deploy
Typing this command deploys
ajaxguessnumber.war
to the GlassFish Serv-
er.
To Run the
ajaxguessnumber
Example
1. In a web browser, type the following URL:
http://localhost:8080/ajaxguessnumber
2. Type a value in the input field and click Submit.
If the value is in the range 0 to 10, a message states whether the guess is correct or
incorrect. If the value is outside that range, or if the value is not a number, an error
message appears in red.
To see what would happen if the JavaScript function were not included, remove
the comment marks from the first
f:ajax
tag in
ajaxgreeting.xhtml
and
place them around the second tag, as follows: