RestJMakiComponents
Creating and consuming RESTful Web Service jMaki Components in Web Applications
This tutorial outlines the steps to create and consume jMaki components build from NB RESTful Web services projects.
To see how to create a mashup using REST jMaki component, go to "How to use Rest JMaki Table component"
Contents |
Preparation:
0. Required Installations:
- JDK 1.6.0_01
- Latest NetBeans 6.0 bits - http://download.netbeans.org/netbeans/6.0/final/ (If you choose Full install, then GlassFish AppServer gets installed also)
- GlassFish V2 - http://download.netbeans.org/netbeans/6.0/final/ or GF website (https://glassfish.dev.java.net/)
- After installing NB 6.0, get NB 6.0 'RESTful Web Services' plugin from the NB 6.0 IDE menu "Tools->Plugins->Available Plugins. After installing the plugin(s), IDE restarts.
- Also install the jMaki Ajax plugin (in IDE follow Tools->Plugins->Available Plugins,
then select 'jMaki Ajax support' and click 'Install' button), as shown below:
Note: You can also download org-netbeans-modules-sun-jmaki.nbm from jMaki Netbeans plugin area and install the plugin seperately.
1. Creating a 'CustomerDB' Web Project
First, you need to create a web project. In this case, we will use one of the samples that is included in the New Project wizard as our starting point.
- Choose File > New Project. Under Categories, select Samples and then RESTful Web Services. Under Projects, select Customer Database, as shown below:
- Click Next and click Finish.
The sample project opens in the IDE, with its project structure in the Projects window.
2. Testing the 'CustomerDB' RESTful Web Services
To test the application, do the following:
- In the Projects window, right click the project and choose Test RESTful Web Services. The server starts and the browser opens, displaying the RESTful web client, which you can use for testing the interaction with the RESTful web service.
- Now, Select the '/customers' link and then click Test. Next, select a customer link (such as '/customers/1/') and then click Test again.
Create jMaki widget
1. Create REST jMaki components from 'CustomerDB' RESTful Web Services
First, you need to create a web project.
- Choose File > New Project. Under Categories, select Web and then enter 'CustomerTestApp', as shown below:
- Click 'Next', then select 'jMaki Ajax Framework', as shown below:
- Invoke action to create REST jMaki components, as shown below:
- Add RESTful Web Service projects, as shown below:
- On 'Finish' jMaki components are created under '/CustomerTestApp/Web Pages/resources/dojo/rest'. A zip file 'CustomerDB.zip' is also created (as shown below). The contents and the structure of the zip file is same as that laid out on the '/CustomerTestApp/Web Pages' directory.
2. Testing CustomerDB jMaki components in 'CustomerTestApp'
To test the application, do the following:
- In the Projects window, navigate to 'TestResourcesTable.jsp', then right click and run this file.
- The server starts and the browser opens, displaying the Customers in a table. You can also do 'Add', 'Update' and 'Delete' operations, thus fulfilling the CRUD (Create, Retrieve, Update and Delete) functionality of a RESTful Web Service (in this case 'CustomerService').
3. Using CustomerDB jMaki components in Web Applications
To use the REST jMaki components in another web project, do the following.
- Invoke Tools -> Palette -> Add jMaki Library
- Load the 'CustomerDB.zip'
- CustomerDB Category with 'Customers Service' and 'DiscountCodes Service' shows up as palette items.
4. Testing CustomerDB jMaki component tags in a Web Application
To test the newly created jMaki components, do the following
- Create a web project.
- Choose File > New Project. Under Categories, select Web and then enter 'MyApp', as shown below:
- Click Next and click Finish.
The sample project opens in the IDE, with its project structure in the Projects window.
- Drag-n-Drop the 'Customers Service' to index.jsp of this app.
A tag entry is made in the jsp page.
- Now run index.jsp
- The server starts and the browser opens, displaying the Customers in a table.
Attachments




















