Junos Space Developer
Reply
Visitor
Rakesh C
Posts: 7
Registered: ‎12-04-2011
0

Unable to invoke particular JS for the Task

Hi All,

 

I'm able to get Task Icon in the App UI but when i click the task icon, unable to get the UI for that particular Task (Means unable to launch the JS). Kindly help me in getting the same with some simple Hello world application and steps to be followed.

 

 

Regards,

Rakesh

Super Contributor
vimala.srinivasa
Posts: 209
Registered: ‎10-07-2010
0

Re: Unable to invoke particular JS for the Task

Hi Rakesh,

    Just ensure the below is correctly configured.

1) Have you uploaded the JS files created using the EST-JS in the module.xml under JS-config correctly

2) Also Ensure that the workspace and Capability are selected for getTask

   Below is the steps which you can go through by deploying the sample application "Library".

 

1)    Download/copy the file Library-Authors-Panel.zip file onto your laptop and unzip it.

It contains the following: Folder    File    Description javaScript files to render the UI for the new task. These files were generated using the Junos Space Ext Designer tool.
    library.AuthorsPanel.js    - This is the top-level JavaScript which constructs the view by instantiating the JavaScript mentioned below
    library.AuthorsPanel.ui.js  -   This JavaScript renders a panel with a grid displaying the collection of authors. The collection of authors is obtained from the JSON Data Store mentioned below
    library.AuthorsStore.js   -  This JavaScript which manages a JSON Data Store by fetching authors from the WebSvc layer using the /api/library/authors API
icons        Icons required for the new task as PNG files.
    Authors_38x38.png    Icon to represent the task.
    Authors_Hover_38x38.png    Hover icon to represent the task.
.    Library-new-ui.xds    The Ext Designer project used to generate the JavaScript code.
2)    Open the module.xml editor in Eclipse using File -> Junos Space -> Edit Module.xml menu option. This opens the Tree View of the module.xml file for this app.
a)    Select all-tasks in the box on the left side. Click on the (+) button to add a new task. A Task Details pane opens on the right side allowing you to configure the new task.
b)    Enter the name of the new task. Suggested: Authors
c)    Enter the title of the new task. Suggested: Authors
d)    Select the application module as “Library”.
e)    Select the workspace as “LibraryWS”.
f)    Select the capability as “LibraryCap”.
g)    Select “Add to Ribbon” as we want the task to be displayed in the ribbon.
h)    Select “Is Enabled by default” as we want the task to be enabled by default.
i)    Enter a Tool tip description for the task.
j)    Under UI Configuration -> JS Config, upload the set of JavaScript files required for this new task, by clicking on the Upload button on the right side. Upload the files in the following order:
i)    library.AuthorsPanel.js ()
ii)    library.AuthorsPanel.ui.js ()
iii)    library.AuthorsStore.js ()
k)    Upload the Task Icon. This icon represents this task in the Ribbon bar. Choose the file Authors_38x38.png.
l)    Upload the Hover Icon. This icon is displayed when hovering the mouse over the task icon in the ribbon bar. Choose the file Authors_Hover_38x38.png.
m)    Upload the Select Icon. This icon is displayed in the Ribbon bar when this task is selected. Choose the file Authors_Hover_38x38.png.
n)    Click on the save button in the Eclipse toolbar. This saves all changes to the module.xml file of this app.
3)    Deploy the app using the steps described in Exercise-6.
4)    Login to the JSVA GUI and choose Library app. Click on the Authors task to see the new UI you configured.


 

Regards,

Vimala.

Visitor
Rakesh C
Posts: 7
Registered: ‎12-04-2011
0

Re: Unable to invoke particular JS for the Task

Thks Vimala,

 

Now I'm able to view UI for a particular Task, Next problem I'm facing is  how to invoke a particular function written in EJB whenever I click a button in UI.

Suppose I've Button in UI for a particular Task and when the User Clicks the Button, My Application should call or invoke a Function written in EJB Class Implementation say HelloUser(). Within the that Function i want to update some data in the UI. Kindly help me in achieving the same with sample application with steps.

 

Regards,

Rakesh

 

 

Super Contributor
vimala.srinivasa
Posts: 209
Registered: ‎10-07-2010
0

Re: Unable to invoke particular JS for the Task

Hi Rakesh,

 

     I suggest you go through the section "Developing Junos Space SDK application" section in eclipse.  The documentation provided in eclipse is very much in detail. 

 

      If you still run through any problem let me know. 

 

 

 

Thanks,

 

Vimala.

Visitor
Rakesh C
Posts: 7
Registered: ‎12-04-2011
0

Re: Unable to invoke particular JS for the Task

Hi Vimala,

 

I've already gone through the eclipse doc but still i'm unable to invoke the methods present in EJB Implementation from UI.

Kindly help with simple example along with the steps and any modifications to be done in the code level.

 

 

Regards,

Rakesh

Super Contributor
vimala.srinivasa
Posts: 209
Registered: ‎10-07-2010
0

Re: Unable to invoke particular JS for the Task

Hi Rakesh,

 

Below are the steps with reference to sample Library application.  The below steps will create a new REST API and invoke the methods.

 

 

1)      Using the Project Explorer tab in Eclipse, select the Library Session Bean interface under:
LibraryEJB -> src -> net.juniper.jmp.library.ejb -> Library.java.
Right-click and choose Create/Edit REST Resources menu option.

2)      This opens the REST Interface Creation wizard. Notice the target project, package, and class that the wizard automatically identifies for generating the REST layer code. Leave these unchanged. Click Next.

3)      This brings you to the page titled Configure REST Resource.

a)      See that the Context Root of the application is “/api/library”. This is coming from the application.xml file in the master project and is read-only here. This is the root URI under which the API of all web services exposed by the app will be placed.

b)      See that the Service Root is “/”. You can change it by clicking on the Edit button. In this exercise, we want all the APIs of this web service to be directly placed under the Context Root – i.e. /api/library/books, /api/library/authors, etc. So, leave this unchanged.

c)       See that all the methods of the selected Library Session Bean are listed in the table. Also, see that the getBooks () method is already mapped into the existing REST interface. That is why it is listed in the second table and not in the first one.

d)      Select the getAuthors (PagingContext) method in the first table and click on Add.

e)      This brings up a second-level wizard that allows you to specify details about mapping the selected method onto the REST layer. The first page is titled Configure REST Method.

i)        Notice that the wizard automatically maps this method to the HTTP Method GET using the @GET annotation. How?

ii)       Notice that the wizard automatically maps this method to the path “/api/library/authors”. How?

iii)     See that the table of parameters for the REST layer method to be generated is empty.

iv)     Now select the option “Sorting/Filtering/Paging” since we want these to be enabled on this new API. Notice that the wizard adds the UriContext parameter with the @Context annotation.

v)      Click Next. This brings up the page showing RBAC details for the new API. Notice the RBAC Capability and RBAC Type chosen by the wizard. Also notice how it is reflected in the method signature preview shown below. Leave these unchanged. Click Next.

vi)     This brings up the page that allows you to configure the REST layer DTO object for this new API. Select “authors” and click on Configure. This brings up a third-level wizard that allows you to select the fields of the Author objects that you want the API to return and configure their properties.

*        See that the table lists all properties of the Author TO class in the EJB layer. Select the following properties. These fields will be returned by the REST API /api/library/authors.
                id
                lastName
                firstName

*        Mark these three properties as sortable and filterable by selecting the corresponding row in the table and clicking on Configure.

*        Select id as the key for the “authors” collection.

*        Click Finish and this returns you to the second-level wizard.

ii)       Click Next. This brings you to the final page of the second-level wizard. This page allows you to configure the media types supported by the REST API that you’re adding. Notice that the option “Both” is automatically chosen by the wizard which means that the API will support both XML and JSON formats.

iii)     Examine the method signature preview shown in this page and observe all the annotations based on your choices in the previous steps.

iv)     Click Finish. This brings you back to the first-level wizard. It now shows that the getAuthors (PagingContext) method is also supported by the REST web-service layer.

b)      Click Finish. The wizard now generates code into the target project/package/class.

2)      Examine the code generated by the wizard:

a)      getAuthors () method added to Library.java in LibraryWebSvc project.

b)      getAuthors () implementation inside LibraryRestImpl.java in LibraryWebSvc project.

c)       Authors DTO class added to LibraryWebSvc project.

 

 

 

Regards,

 

Vimala.

 

Visitor
Rakesh C
Posts: 7
Registered: ‎12-04-2011
0

Re: Unable to invoke particular JS for the Task

Hi Vimala,

 

Thks for your reply....But i'm not understanding how getAuthors() returns the list of data(how to create and maintain database with JUNOS) and how the returned data is being updated to UI (How is the link maintained). Kindly attach the Library application Zip..

 

                    What I tried is, I've created the Sample HelloWorld application within that I have implemented only one method HelloUser() which returns a String saying "Hello World", and i've created Rest Api for the same method with steps mentioned as per you and in docs. But what i want is to invoke this HelloUser() when a user clicks a Button(Which I've created in UI) and print the the "Hello World" returned from the HelloUser() within textfield in UI. But I'm not getting the accepted result.

 

Regards,

Rakesh

 

Super Contributor
vimala.srinivasa
Posts: 209
Registered: ‎10-07-2010
0

Re: Unable to invoke particular JS for the Task

Hi Rakesh,

 

       I am trying to do the same i have method getAuthors() and i created new REST API and invoked the same on the UI 

 

       You can create a DB if necessary from eclipse during build/deploy Junos Space application.  The Libraryapplication is already attached in my first conversation with you.  Pl. see the first response to your query posted. 

 

      It will good if you can bundle your application i can take a look if there is some issue.

 

 

 

 

 

Regards,

 

Vimala.

Visitor
Rakesh C
Posts: 7
Registered: ‎12-04-2011
0

Re: Unable to invoke particular JS for the Task

Hi Vimala,

 

PFA of the test application(Dur to attachment zip size constrains, will attaching onle the HelloUserEJB, HelloUserWeb, HelloUserWebSVC folder in the Zip ). In which when user clicks the Button i want to call HelloUser() method which is implemented in HelloUserImpl.java, In response the String("HelloUser!!!") returned by the method should be updated in the UI (TextArea).

 

Issues:

1)  During the Restification of the HelloUser() method the Context Api Path showed in Configure REST Resource was /api/rakesh/hello-user. Is it Correct ?

 

2) Kindly help in understanding the use and working with Data store component  in EXT Designer tool.

 

The Library application.zip attached during conversion contains only UI part(Java Scripts file) not complete Application code, Kindly attach the same.

 

Regards,

Rakesh

Super Contributor
vimala.srinivasa
Posts: 209
Registered: ‎10-07-2010
0

Re: Unable to invoke particular JS for the Task

Hi Rakesh,

 

    I will look into the issue with your application.  

 

    Can you please send a mail to vimalas@juniper.net address the file is huge to attach.   

 

 

Regards,

 

Vimala.

Copyright© 1999-2013 Juniper Networks, Inc. All rights reserved.