| 3 | | IT Mill Toolkit manual has detailed instructions on how to create your first |
| 4 | | project with IT Mill Toolkit in Eclipse IDE. This article shows you how to accomplish |
| 5 | | the same using [http://www.netbeans.org Netbeans IDE 6.1] instead of Eclipse. This tutorial assumes you have |
| 6 | | downloaded a bundle of Netbeans 6.1 that includes the Apache Tomcat server (for example |
| 7 | | the "Web & Java EE" package) and the latest release of [http://www.itmill.com/downloads/itmill-toolkit.htm IT Mill Toolkit]. |
| 8 | | |
| 9 | | == Creating the Project == |
| 10 | | |
| 11 | | [[Image(new-project-dialog.png, 500px, align=right)]] |
| 12 | | Launch your Netbeans IDE and follow the following steps to create a new web project using IT Mill Toolkit. |
| 13 | | |
| 14 | | * Select '''File -> New Project''' to open the New Project dialog window. |
| 15 | | * Select '''Web''' from the categories and '''Web Application''' from the project selection and click '''Next''' to proceed. |
| 16 | | * Type in a name and location for your project (I use {{{HelloToolkit}}} as the name and my default project folder) and click '''Next'''. |
| 17 | | * Select the '''Apache Tomcat 6.0.16''' server if not already selected and type in preferred context path or use the default |
| 18 | | (the project name). The context path will define the URL of your application (for example {{{http://localhost:8084/HelloToolkit}}}). |
| 19 | | Click '''Finish''' to create the project. |
| 20 | | * You can close and ignore the index.jsp, which is opened to the editor by default after the project has been created. |
| 21 | | |
| 22 | | |
| 23 | | == Including IT Mill Toolkit Libraries == |
| 24 | | |
| 25 | | Next you need to include the IT Mill Toolkit library JAR package to the project you just created. |
| 26 | | |
| 27 | | * Right-click the '''Libraries''' node on your project and select '''Add JAR/Folder'''. |
| 28 | | * Select your copy of the IT Mill Toolkit JAR package from the opening file dialog. |
| 29 | | * Now you should see the JAR package under the Libraries node. |
| 30 | | |
| 31 | | == Writing the Code == |
| 32 | | |
| 33 | | Next we create the application class for our simple example application. |
| 34 | | |
| 35 | | * Select '''New -> Java Class''' on your project to open the New Java Class dialog. |
| 36 | | * Type in your a name and package for your class (I use a class name of {{{HelloToolkit}}} and a package {{{com.itmill.toolkit.netbeans.tutorial}}}). |
| 37 | | * Select '''Finish''' to create the Java class. |
| 38 | | |
| 39 | | This class will be the main application class of our IT Mill Toolkit application. |
| 40 | | Therefore it must extend the abstract {{{com.itmill.toolkit.Application}}} class and implement the {{{init()}}} method. |
| 41 | | |
| 42 | | Type in or copy-paste the following code to the newly created file: |
| 43 | | |
| 44 | | {{{ |
| 45 | | #!java |
| 46 | | package com.itmill.toolkit.netbeans.tutorial; |
| 47 | | |
| 48 | | import com.itmill.toolkit.Application; |
| 49 | | import com.itmill.toolkit.ui.Label; |
| 50 | | import com.itmill.toolkit.ui.Window; |
| 51 | | |
| 52 | | public class HelloToolkit extends Application { |
| 53 | | |
| 54 | | @Override |
| 55 | | public void init() { |
| 56 | | Window mainWindow = new Window("Hello Toolkit window"); |
| 57 | | mainWindow.addComponent(new Label("Hello Toolkit")); |
| 58 | | setMainWindow(mainWindow); |
| 59 | | } |
| 60 | | |
| 61 | | } |
| 62 | | }}} |
| 63 | | |
| 64 | | |
| 65 | | == Defining Deployment Descriptor == |
| 66 | | |
| 67 | | To run your application you must define a deployment descriptor for it. Open '''Web Pages -> WEB-INF -> web.xml''' file on your project. |
| 68 | | By default the file is opened in a graphical editor but you can select the XML tab to edit the XML file directly. Type in or |
| 69 | | copy-paste the following to the contents of the file. |
| 70 | | |
| 71 | | {{{ |
| 72 | | #!xml |
| 73 | | <?xml version="1.0" encoding="UTF-8"?> |
| 74 | | <web-app version="2.5" |
| 75 | | xmlns="http://java.sun.com/xml/ns/javaee" |
| 76 | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 77 | | xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> |
| 78 | | |
| 79 | | <servlet> |
| 80 | | <servlet-name>HelloToolkit</servlet-name> |
| 81 | | <servlet-class>com.itmill.toolkit.terminal.gwt.server.ApplicationServlet</servlet-class> |
| 82 | | <init-param> |
| 83 | | <param-name>application</param-name> |
| 84 | | <param-value>com.itmill.toolkit.netbeans.tutorial.HelloToolkit</param-value> |
| 85 | | </init-param> |
| 86 | | </servlet> |
| 87 | | |
| 88 | | <servlet-mapping> |
| 89 | | <servlet-name>HelloToolkit</servlet-name> |
| 90 | | <url-pattern>/*</url-pattern> |
| 91 | | </servlet-mapping> |
| 92 | | |
| 93 | | </web-app> |
| 94 | | }}} |
| 95 | | |
| 96 | | == Running Your Application == |
| 97 | | |
| 98 | | Now we can run (or debug) the application by simply selecting '''Run -> Run Main Project''' (or '''Run -> Debug Main Project'''). |
| 99 | | This starts the Apache Tomcat server and opens up your application in your default browser. |
| 100 | | |
| 101 | | [[Image(hello_toolkit_running.png, 632px)]] |
| | 3 | This article has been moved here: |
| | 4 | http://vaadin.com/wiki/-/wiki/Main/Getting%20Started%20on%20NetBeans?p_r_p_185834411_title=Getting%20Started%20on%20NetBeans |