- PrimeFaces Theme Development
- Andy Bailey Sudheer Jonna
- 785字
- 2021-07-09 21:12:21
Creating a NetBeans Maven JSF project
After launching NetBeans, open the File menu and select New Project from the available project types. Locate and select Maven. A list of Maven archetypes (project templates) is available. Select Web Application, as shown in the following screenshot:

Click on Next and the following screenshot appears:

Project Name is set to PFThemes
.
Project Location is generated automatically and it does not need to be changed.
The following Maven properties are listed:
- Artifact Id: This cannot be changed. It is the name of your project.
- Group Id: This can be edited as required. This sets the base package for the project.
- Version: This does not need to be changed.
- Project: This is the last property that we will use to set the root package for all the Java classes in the project.
Now that we have set the name and location of the project, click on Next. This leads us to the Settings dialog box. This is where we set the application server and Java Enterprise Edition (EE) version that we are going to use for the project, as shown in the following screenshot:

I chose GlassFish because it is the Java EE reference implementation. I selected GlassFish Server 4.0 because this is the current release version of GlassFish and the nightly builds are available to me.
Tip
You can use any Java EE 7 container that supports the Java EE 7 web profile that you like. The list of potential servers is long, but Tomcat (http://tomcat.apache.org/), TomEE (http://tomee.apache.org/), and WildFly (http://wildfly.org/) are suitable ones. Tomcat and TomEE are freely available from the Apache Software Foundation (http://apache.org/)and WildFly is available from RedHat.
Once we have set the project settings, we can finish creating it. NetBeans presents us with a Project view containing our newly created project. If it hasn't opened a Project view, open the Windows menu and select Projects. You can also open a Files and a Services view. This allows us to check the files as they are built into the project, and through the Services view we can control things such as the GlassFish server, as well as other services such as database connections.
Now that we have successfully created the project, we have to change the project properties so that it adds the JSF framework to it.
Note
The JSF framework is part of the Java EE 7 standard version. It allows developers to build views/pages that are separate from the business logic and data models that make up the middle tier of data-driven applications. Because PrimeFaces builds on the facilities provided by JSF, we need to add it to our project.
Select the project and right-click on it. This opens a context menu, which allows us to perform different tasks and control various aspects of the project itself. We are interested in the one at the bottom, Properties. We click on it to open the Project Properties dialog box and select the Frameworks option, as shown in the following screenshot:

By clicking on the Add… button to the right, we can select a framework from a number of choices. We want JSF, so we select it and click on OK, as follows:

We return to the Project Properties | Frameworks dialog box, which looks like this:

The three tabs, Libraries, Configuration, and Components, are used to display and/or change the configuration of the JSF framework for our project. Libraries cannot be altered, but it shows that we are using Java EE 7 JSF version 2.2. I also changed the configuration as follows:

The JSF Servlet URL Pattern field has been changed to *.xhtml
from the default one because it makes the linking of JSF pages easier. However, this is a purely personal preference and it is not something that you need to do.
Once you have set up the JSF framework to your satisfaction, click on OK, and the changes will be applied to our project.
Tip
While we have been doing this, NetBeans should have been building the project in the background, including the creation of the project from its Maven archetype. Maven downloads quite a large number of files when a project is created. Luckily for us, it only does this once. Maven also maintains a local repository of resources on our workstation for us so that once a file is downloaded from the Maven Central Repository it doesn't need to be download from there again.
- Learning Cython Programming
- JavaScript 從入門到項目實踐(超值版)
- Learning JavaScript Data Structures and Algorithms
- Corona SDK Mobile Game Development:Beginner's Guide(Second Edition)
- Python大學實用教程
- 軟件測試綜合技術(shù)
- 玩轉(zhuǎn).NET Micro Framework移植:基于STM32F10x處理器
- Java Hibernate Cookbook
- Mastering Embedded Linux Programming
- Keil Cx51 V7.0單片機高級語言編程與μVision2應用實踐
- 和孩子一起學編程:用Scratch玩Minecraft我的世界
- JavaScript Unit Testing
- Visual C#(學習筆記)
- Python程序設計教程
- Image Processing with ImageJ(Second Edition)