Creating an IntelliJ IDEA 5.0 Project using NetUI
This page describes the steps necessary to get a the netui-blank webapp running inside of IntelliJ IDEA 5.0. These steps are based upon the 1.0 release of Beehive and the documentation provided for that release. Currently, this points to the nightly documentation. These steps also assume that Tomcat is the target Servlet container. It should be simple to adopt these instruction for older versions of IDEA such as 4.5.
[NOTE: Once we do the 1.0 release, we need to point the links to the official 1.0 documentation.]
Create the Project
These steps are the preliminary steps that creates a new Beehive NetUI project. These steps are found in the documentation for NetUI.
First you must setup your environment. Complete all of the steps in the "Beehive Setup and Installation" topic.
Complete the sets to setup a new webapp. These instruction are found in the "NetUI Project Template" topic. With this step, do an ant build in the project root to confirm that the steps have worked. This will also create the build directory which is the expanded webapp that would be deployed to the server. At this point you should have the following three directories below the project root.
- build -- The directory that is the expanded webapp
- src -- The directory containing the source files
web -- The directory containing the webapp content(.JSPs, Images, etc) plus the WEB-INF directory. Note: at the moment the root page flow controller Controller.java is found in this directory.
Create a new IDEA Project
This set of sets will create the IntellJ IDEA 5.0 project. These steps follow the pages of the wizard. A few of the page do not require modification, but are mentioned.
Open up IDEA and create a new project (File -> New Project).
- The first page of the dialog should come up. Enter a name for the project and a place for the project file location. Then hit [Next].
- Select a 1.5 JDK from your list of JDKs. Then hit [Next].
- Select 'Create single-module project'. Then hit [Next].
Select the module type Web Module. Then hit [Next].
The module name should be the same as the project name. For the Module content root, select the root of your project. This is the directory that contains the build, src, and web directories along with the build.xml and build.properties files. NOTE: in the rest of this document, the project root is identified as $project-root$ Then hit [Next].
- Select an application server, in this case select "Tomcat". Then hit [Next].
On the deployment descriptor page, modify the Web Module Deployment Descriptor by selecting it and hitting the [Edit] button. First change where the Deployment descriptor is located. You should select the $project-root$\web\WEB-INF\web.xml deployment descriptor. Second change the Deployment descriptor version to 2.4. Once you've changed the deployment descriptor hit [Next].
Set your Web resource directory to be $project-root$\web. Then hit [Next].
Set your exploded directory to be $project-root$\build. Then hit [Next].
Java Source is found in both the src and the web directories because the Controller.java is currently found in the web content. Hit [Next].
Compiler output should be directed to $project-root\build\WEB-INF\classes. Hit [Finish]. At this point your project has been created.
In order to get your project to compile correctly and run inside IDEA, you need to do the following within the project. You won't actually compile the project using IDEA, instead you need to use the ant files. This step is necessary so that you don't recieve errors in your Java source as you develop page flows and supporting classes.
Open the project settings and select the Libraries (Classpath) tab.
Hit the Add Jar/Directory... button.
Add all of the .jar files from the $project-root$/build/WEB-INF/lib directory to the project.
- Hit [OK] and exit the Project Settings page.
At this point, you should be able to build the project without any errors. You can't do an actual build from IDEA, but instead must use the ant commands found in the ant build.xml file.
Setup Ant For Build
The following steps will setup ant to run correctly inside your IDEA project.
Open the 'Ant Build' view and add [+] the $project-root$/build.xml file. You should see a set of commands including:
- Right click the ant file and pull up the Build File Properties dialog.
On the Properties tab, enter the following property (name = 'os.CATALINA_HOME', value='Tomcat-Location') where 'Tomcat-Location' is the root directory for you Tomcat installation. Hit [OK] on the dialog.
Building the Project
At this point you should be able to build the project using ant. To confirm this, run the ant clean command followed by the build command. The results may contains warning but shouldn't have any errors.
Running the Project
In order to run/debug in your new project do the following:
Create a new configuration [run -> edit configurations].
Select the Tomcat Server tab
- Hit the [+] button and select 'local'
Give the configuration a Name.
- Select the Tomcat Application Server
Uncheck the Make Module before running/debugging/reloading because we this project assume that the project is built using ant.
- Press [OK] to save the new configuration.
At this point you should be able to run the project by hitting the [debug] or [run] buttons. When you run it, the server should start and a browser window will open showing you the default page flow.
In order to do iterative dev within the page flow, you do the following:
- Make some modification to a page flow, for example add a new action.
Make a modification to a .JSP file, for example add a <newui:anchor> to call the action
Using ant, do another build
In the Run - $Configuration$ window hit the Deploy All button which will deploy the changes to the server
- In your browser window hit refresh. You should see the change to the page and if you press the link the action should run.