Configure Worklight properties
Configure the Worklight properties to add the preferences to the portal page.
The wp_worklight module requires a wl_config module defined in...
PORTAL_HOME\theme\wp.theme.worklight.ext\installedApps\wp.theme.worklight.ext.ear\wp.theme.worklight.ext.war\WEB-INF\plugin.xml
- Use the wl_config module to load the Worklight configuration properties.
<extension point="com.ibm.portal.resourceaggregator.module" > <module http://setgetweb.com/p/hcl95/dev-theme/hcl151.html#wl_config">wl_config"> <runtimeActivation> <condition deviceClass="worklight"/> </runtimeActivation> <contribution type="config"> <sub-contribution type="config_dynamic"> <uri value="wl:id" /> </sub-contribution> </contribution> </module> </extension>
- To activate the Worklight configuration properties, add the following parameter to the URL from the hybrid application...
?uri=wl:id:appid
...where the appid is replaced with the actual application ID in Worklight. After it is activated, the Worklight configuration properties are dynamically injected from the application HTML file to the portal page. For example:
<script> // Define WL namespace. var WL = WL ? WL : {}; /** * WLClient configuration variables. * Values are injected by the deployer that packs the gadget. */ WL.StaticAppProps = { "APP_DISPLAY_NAME": "DemoApp", "APP_SERVICES_URL": "\/apps\/services\/", "ENVIRONMENT": "iphone", "LOGIN_DISPLAY_TYPE": "embedded", "POSTFIX_APP_SERVICES_URL": "\/apps\/services\/", "POSTFIX_WORKLIGHT_ROOT_URL": "\/apps\/services\/api\/DemoApp\/iphone\/", "WORKLIGHT_ROOT_URL": "\/apps\/services\/api\/DemoApp\/iphone\/" }; </script>
- Configure the Worklight configuration properties through JavaScript. For example, use this code:
WL.StaticAppProps.ENVIRONMENT
- If the application needs configuration properties in addition to the base ones provided, we can mix them into this WL.StaticAppProps object with JavaScript. For example:
<script type="text/javascript"> i$.bindDomEvt(window, "onload", function(evt) { if (window.WL && window.WL.StaticAppProps) { window.WL.StaticAppProps.APP_VERSION = "1.0"; window.WL.StaticAppProps.WORKLIGHT_PLATFORM_VERSION = "6.1.0"; } }); </script>
- Inject the JavaScript code created onto the page from the theme.
We can add the code created to one of the existing dynamic content spot .jsps or create a new dynamic content spot. Or, we can add the JavaScript to an HTML file in an existing or new module.