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:



Image:InstallRestPlugin_RestJMakiComponents.png

  • 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:


Image:InstalljMakiPlugin_RestJMakiComponents.png

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:



Image:CreateCustomerDB_RestJMakiComponents.png

  • 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.


Image:TestCustomerDB_RestJMakiComponents.png

  • Now, Select the '/customers' link and then click Test. Next, select a customer link (such as '/customers/1/') and then click Test again.


Image:TestPage_RestJMakiComponents.png

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:


Image:CreateClientApp_RestJMakiComponents.png

  • Click 'Next', then select 'jMaki Ajax Framework', as shown below:


Image:SelectjMakiFramework_RestJMakiComponents.png

  • Invoke action to create REST jMaki components, as shown below:


Image:GenerateClientComponents_RestJMakiComponents.png

  • Add RESTful Web Service projects, as shown below:


Image:AddCustomerDB_RestJMakiComponents.png

  • 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.


Image:ZipStructure_RestJMakiComponents.png


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.


Image:RunjMakiTest_RestJMakiComponents.png

  • 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').


Image:DojoResult_RestJMakiComponents.png

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


Image:AddNewComp_RestJMakiComponents.png

  • Load the 'CustomerDB.zip'


Image:AddNewComp1_RestJMakiComponents.png

  • CustomerDB Category with 'Customers Service' and 'DiscountCodes Service' shows up as palette items.


Image:CustomerDBService_RestJMakiComponents.png


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:


Image:NewAppConsumejMaki_RestJMakiComponents.png

  • 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.


Image:CustomerDBServiceDnD_RestJMakiComponents.png

A tag entry is made in the jsp page.

  • Now run index.jsp


Image:RunJsp_RestJMakiComponents.png

  • The server starts and the browser opens, displaying the Customers in a table.


Image:MyAppCustomerDBResult_RestJMakiComponents.png

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo