+

Search Tips   |   Advanced Search

Use jQuery in a theme


IBM WebSphere Portal uses the Dojo JavaScript library. The iWidget container, Tagging and Rating component, the Web Content Authoring portlet, the inline editing component in the Web Content Viewer portlet, and page editing capabilities from the Page Builder theme all rely on the Dojo library. We can create a jQuery module and use that module to manipulate the portal page. The example here is not meant to show a full replacement of the dojo framework with jQuery but rather to show the basics of how to use jQuery with WebSphere Portal. For the example, jQuery is used to create a collapsible section from the header and footer of a portal page that is using the default layout for the Portal 8.0 theme.

Define the jQuery module, include it in the theme profile, and apply the profile to a page. Define the module, start by creating a plugin.xml file for the module. The example defines a head extension point that includes the jquery.min.js file. The example uses the jquery.min.js file placed in the main Theme Modules directory for the WebSphere Portal 8.0 theme. The jquery.min.js file can be placed elsewhere. In addition to the main jQuery extension point, two more extension points are defined. These extensions define the css and JavaScript needed to create the collapsible sections. For more information about the plugin.xml format, see Registering theme modules and profiles.

After the module is defined, add this module to the theme with a profile. Copy the profile_lightweight.json file in the WebDAV directory fs-type1/themes/Portal8.0/profiles to a new file named profile_jQuery.json. To this profile add jQuery and jSquishy. To use this profile set it on a portal page using the resourceaggregation.profile page metadata file. For more information about this task, see Defining module used to render a page.

Finally, restart the portal server to enable the new modules. The pages using this new profile now includes jQuery and has the collapsible header and footer sections.

To use this example:

  1. Create the files listed in the table.

  2. Set the sample page’s metadata resourceaggregation.profile to profiles/profile_jQuery.json.

  3. Restart the portal server.


Location of files used in this example

File name Installed location
jquery.min.js PORTAL_HOME/theme/wp.theme.modules/webapp/installedApps/ThemeModules.ear/ThemeModules.war/jQuery/1.6.3/jquery.min.js
plugin.xml Use the java jar command to create a jQuery.jar file that includes the plugin.xml file.
jQuery.jar PORTAL_HOME/theme/wp.theme.modules/webapp/installedApps/ThemeModules.ear/ThemeModules.war/WEB-INF/lib/jQuery.jar
profile_jQuery.json WEB Dav location: fs-type1/themes/Portal80/profiles/profile_jQuery.json
jSquishy.css PORTAL_HOME/theme/wp.theme.modules/webapp/installedApps/ThemeModules.ear/ThemeModules.war/jQuery/css/jSquishy.css
jSquishy.js PORTAL_HOME/theme/wp.theme.modules/webapp/installedApps/ThemeModules.ear/ThemeModules.war/jQuery/js/jSquishy.js
jSquishy.jsp PORTAL_HOME/theme/wp.theme.modules/webapp/installedApps/ThemeModules.ear/ThemeModules.war/jQuery/markup/jSquishy.jsp


List of files used in this example


Parent: Customize the theme
Related:
Specify profile files
Related:
Registering theme modules