Skip to main content link. Accesskey S
  • Anonymous
  • Log on
  • Help
  • IBM logo
  • IBM Composite Applications wiki
  • All Wikis
  • Home
  • Community Articles
  • Product Documentation
  • Learning Center


Search

Advanced Search

Categories

Tag Cloud

  • 6.2
  • 6.2.1
  • 8.0.1
  • 8.5
  • 8.5+
  • 8.5.1
  • advanced features
  • advantages
  • API
  • app dev
  • assembling
  • basics
  • benefits
  • Browser
  • CAE
  • catalog
  • changing page properties
  • changing value to another type of value
  • code snippet
  • component library
  • component properties
  • components
  • Composite Application Editor
  • Composite Applications
  • container components
  • containers
  • custom actions
  • debugging
  • demos
  • deploying
  • designing
  • developing
  • Eclipse
  • Eclipse components
  • editing properties
  • Editor
  • education
  • enablement
  • Expeditor
  • extending
  • extensions
  • FAQ
  • feature rules
  • framework
  • getting started
  • Help
  • HOD
  • host on demand
  • how to
  • Java
  • lead manager
  • linking
  • live text
  • match rules
  • new users
  • Notes
  • Notes components
  • nsf
  • NSF components
  • overview
  • page navigation
  • page properties
  • Palette
  • PBE
  • PIM
  • plugins
  • Portal
  • preference
  • product documentation
  • programming
  • properties
  • property broker
  • property broker editor
  • Property Broker Monitor tool
  • provisioning
  • resources
  • roadmap
  • samples
  • setting component properties
  • Sidebar
  • sideshelf
  • Symphony
  • Symphony view component
  • technote
  • testing
  • toolkit
  • TopologyHandler
  • troubleshooting
  • tutorial
  • update site
  • updating
  • upgrading
  • video
  • view
  • Web
  • web services
  • white lists
  • widgets
  • Wiring
  • WSDL
InformationInformation
You are currently viewing machine translated content. IBM translation might be available. Click IBM Translated Product Documentation to see what is available.X


Home > Tutorials: Intermediate > Create a custom container action that executes JavaScript.
Rate this article 1 starRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Create a custom container action that executes JavaScript. 

expanded Abstract
collapsed Abstract
No abstract provided.
ShowTable of Contents
HideTable of Contents
    • 0.1 Prerequisites
    • 0.2 Creating the plugin
    • 0.3 Packaging and Installing your plugin
    • 0.4 Creating a new composite application
    • 0.5 Assembling your application
    • 0.6 Using the new action
    • 0.7 Conclusion
During this tutorial you will create a custom action that can run javascript. For this tutorial we are going to build off of the Creating custom actions in Java tutorial. The Creating custom actions in Java tutorial defines what a custom action is and also walks the user through all the steps of creating a plug-in, an action class, a feature and an update site. The custom action tutorial also shows the user how to install their site into Lotus Notes. All of the steps from that tutorial will need to be done here as well. Please follow the steps in that tutorial. The difference here is just going to be in our action class since we are creating a different action. The main point of this article is to show the user how easy it is to create another custom action and also show them a simple class that can call JavaScript methods in a browser with input from another component.


Prerequisites



You will need Lotus Notes 8.5.1 and the Lotus Expeditor 6.2.1 toolkit installed into your Eclipse 3.4 IDE.  You will be able to create the sample if you do not have the toolkit as long as you define your Target Platform to be your Notes 8.5.1 installation.
It will be best if you have done the Creating custom actions in Java tutorial prior to performing this one. You will at least want to have read through the other tutorial so you are familiar with all the concepts and are able to create a plug-in, feature and update site in Eclipse.




Step One

Creating the plugin



At this point it is assumed you have followed the Creating a custom action in Java tutorial and have a new plug-in that will contain the class we are about to create. If you have not done this please read that tutorial now.


a) Create a new plug-in as detailed in Step 1 of Creating a custom action in Java. For this tutorial lets name the plug-in that we create com.ibm.ca.wiki.javascript.

b) Extend the com.ibm.rcp.composite.container.core.actionConfigurationextension-point. This is described in detail in Step 2 of Creating a custom action in Java.

The parameter values of your actionConfiguration extension need to be correct for this tutorial. Include the correct class name as created in the previous step (com.ibm.ca.wiki.javascript.ExecuteJS). Enter ExecuteJS as the id.

c) Refer to Step Three of the Creating a custom action in Java tutorial for detailed steps on creating a Java class in Eclipse. For this tutorial please name you new class executeJS.


Here is our executeJS action class. The execute method will get the BrowserAppContainer so that we can get the property values. It will also get the Browser instance so that it can call execute
on the browser the the propert Java scipt method. This will become more clear when we assemble this composite application below.


importjava.util.ArrayList; 

importorg.eclipse.swt.widgets.Display; 

importcom.ibm.rcp.browser.service.WebBrowser; 
importcom.ibm.rcp.composite.container.browser.BrowserAppContainer; 
importcom.ibm.rcp.composite.container.browser.view.BrowserAppView; 
importcom.ibm.rcp.composite.container.core.AppContainer; 
importcom.ibm.rcp.composite.container.core.actions.Action; 
importcom.ibm.rcp.composite.container.core.events.LandmarkEvent; 

publicclass executeJS extends Action
{ 
                publicvoid execute(AppContainer container, LandmarkEvent event, Object context) { 
                BrowserAppContainer c = (BrowserAppContainer)container; 
                         
                String value = (String)this.getData().get("jsMethod"); 
                 
                if(value!=null) 
                {         
                        // myJSMethod(%p1, %p2, %p3) 
                        String params[] = value.split("%"); 
                         
                        for(int i=1; i < params.length; i++) 
                        { 
                                params[i] = params[i].substring(0,2); 
                                if(params[i].equals("p0")) 
                                        value = value.replace("%"+params[i], (String)c.getPropertyValue(this.property));         
                                else 
                                        value = value.replace("%"+params[i], (String)this.getData().get(params[i])); 
                        } 
                 
                        final String jsMethod = value; 
                         
                        if (value != null && !value.equals("")) 
                        { 
                                                                 //once we know we have a value to call execute with on the browser we need to get the browser instance
                                BrowserAppView bView = (BrowserAppView)c.getContainerPart();
                                final WebBrowser browser = (WebBrowser)bView.getWebBrowser();
                                 
                                 
                                // Browser has to run on the UI Thread 
                                Display d = Display.getDefault(); 
                                d.asyncExec(new Runnable(){ 
         
                                        publicvoid run() { 
                                        browser.execute(jsMethod);         
                                        } 
                                                 
                                });         
                        } 
                }                         
        } 
}




Step Two

Packaging and Installing your plugin



Please follow the steps in the Creating a custom action in Javatutorial to create an Eclipse feature that contains our new plug-in. Also follow the steps for creating an Install/Update site and installing the site into Notes.
We can name the feature com.ibm.ca.wiki.javascript.feature. This new feature is the feature you will add to the update site.




Step Three

Creating a new composite application



Please refer to Step Five a) in Creating a custom action in Java tutorial for instructions on creating a new composite application in Notes. For this tutorial please name your new application JavaScript_App.




Step Four

Assembling your application



To assemble this composite application we are going to add a Managed Browser component and the Notes Contacts component. For the Managed Browser we are going to set the URL to a custom html page that is provided as part of this tutorial (jsActionTutorial.html)
and contains some java script functions.

Below is a screen shot of what this page looks like in a browser. Our custom action class above will allow us to wire output from another component to these actions.

With the experience of the previous Creating a custom action in Java tutorial and the detailed steps included in the html page you should be able to assemble your application. The first step in the Test setup section of the html file is referring to the feature we created above
that contains our new custom action executeJS.




Below is a screen shot of our application in CAE. We have added the browser and set the initial URL to the local html file.

In this case of the sample here our 'other component' is the Notes Contacts view and we can wire any of the properties that output strings to our new custom action. Such as LastName or FullName.




Component properties of our Managed Browser. This shows where we defined the initial URL to be our local html file that contains Java Script functions.





Step Five

Using the new action



Now that your application is assembled and wired as specified in the html file you can initiate your action and witness the Java Script functions being invoked by selecting one of the users in your Contacts view. Save and exit the CAE and run the application.




Conclusion



The idea of this tutorial was to add another example action and is not nearly as detailed as the tutorial referenced throughout this. It is very important to read and perform the steps in that tutorial prior to doing this one
if you want a better understanding of what is happening and to know how to perform all of the steps.




expanded Article information
collapsed Article information
Category:
Tutorials: Intermediate
Tags:
JavaScript, Web, containers, custom actions, samples, code snippet, tutorial

This Version: Version 5 October 11, 2009 7:50:33 PM by Deanna Drschiwiski  IBMer

expanded Attachments (1)
collapsed Attachments (1)

 


File TypeSizeFile NameCreated On
text/html 8 KB jsActionTutorial.html 9/8/09 9:32 AM
expanded Versions (5)
collapsed Versions (5)
Version Comparison     
Version Date Changed by               Summary of changes
This version (5) Oct 11, 2009 7:50:33 PM Deanna Drschiwiski  
4 Sep 9, 2009 8:54:42 AM Bob Balfe  
3 Sep 9, 2009 8:48:45 AM Bob Balfe  
2 Sep 8, 2009 10:58:45 AM Bob Balfe  
1 Sep 8, 2009 9:28:16 AM Bob Balfe  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedSubscribe to RSSHelpAbout
  • All Lotus and WebSphere Portal wikis
  • IBM developerWorks
  • IBM Software support
  • IBM Social Business User Experience Blog
  • IBMSocialBizUX on Twitter
  • IBMSocialBizUX on Facebook
  • Lotus product forums
  • IBM Social Business UX blog
  • IBM Collaboration Solutions
  • Recently added feedRecently added
  • Recently edited feedRecently edited
  • Recently added comments feedRecently Added Comments
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Contact IBM
  • IBM Terms of use
  • Wiki terms of use