I suppose
you already have installed NetBeans 8.0.2 and we will install/configure WildFly
AS 8.2.0 Final. Afterwards, we will deploy and run an JSF/OmniFaces sample
application. So, let's see the steps:
Download WildFly 8 AS Distribution
1. Download
WildFly AS 8.2.0 Final from wildfly.org
2.
Un-zip the archive content on your machine
Install WildFly 8 AS under NetBeans 8.0.2
3. Launch
NetBeans 8.0.2 and open the Servers wizard (from Tools | Servers,
or Services
panel | Servers
node | right click and select Add Server ...). You should see this (locate
and select WildFly
Application Server):
4. After
you click the Next
button, you have to navigate to the local folder where you have un-zipped the
WildFly distribution. For this click the Browse... button
corresponding to the Server Location section. The Server Configuration
section will be automatically filed by NetBeans after your selection:
5. Now,
click the Next
button. The next wizard page is automatically filled by NetBeans, and it
contains the default domain, domain path, host and port. Most likely you will
not need to modify these settings:
6. So,
click the Finish
button and the WildFly is ready for use. We can easily perform a quick
start-stop test from Services panel | expand Servers node | right click
on WildFly
Application Server and select Start option. Wait until the WildFly
starts and you will see something as below:
7. From
the same place you can stop WildFly, by selecting the Stop option:
Configure access to WildFly 8 AS admin console
8. This
is a good moment to configure access to WildFly administration console. By
default WildFly 8.2 is distributed with security enabled for the management
interfaces, this means that before you connect using the administration console
or remotely using the CLI you will need to add a new user. This can be achieved
simply by using the add-user.sh script in the bin folder. Basically, you need
to select the option a, and indicate a user and a password:
9. The
user and password from above will be used as credentials for accessing the
WildFly Administrator Console (http://localhost:9990/console/App.html#home) as
in figure below:
Create a JSF/OmniFaces application with NetBeans 8.0.2/WildFly 8 AS
10.
Create a classic Maven Web Application by
selecting the Web
Application project type under the Maven category. Further, provide
a name to the application (e.g. TestApp).
11.
Next, select the WildFly server from the
available servers on your machine and click the Finish button
12. After
the project is created, you need to add the JSF distribution. The "recommend way to use JSF with Maven is to
develop on a Java EE certified container and declare a <provided> scope dependency on the appropriate
version of the Java EE API jar" source: Mojarra JavaServer Faces download page.
For example add in the pom.xml file the next dependency (more
examples of adding JSF with Maven can be found here - choose the one that fits
your needs).
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>2.0</version>
</dependency>
14. Finally,
write a simple JSF page using JSF and OmniFaces tags (e.g. display an byte[]
image using <o:graphicImage>):
...
<h:body>
<h:panelGroup layout="block"
style="background-color: activecaption; text-align: center;
padding:20px;">
<o:graphicImage
value="#{imageBean.imageAsByteArrayFromResource()}"/>
</h:panelGroup>
</h:body>
...
Simply run the application!
The complete code on GitHub.
Niciun comentariu :
Trimiteți un comentariu