Oracle UCM jQuery Plugin for AJAX

I recently put together a jQuery plugin for Oracle UCM, and thought I'd share. This connector allows you to use jQuery to make UCM Service calls through AJAX, and easily display the results. This is 100% pure JavaScript, no Java, Idoc, or ADF required! You can download the plugin from the Bezzotech library page.

You will need to be familiar with jQuery before you can use this plug-in. You can start with the jQuery tutorial at W3Schools.

This plug-in is essentially a collection of wrappers around the $.post() method in jQuery, to allow you to more easily make AJAX calls to Oracle UCM. For example, in order to make a "Test Connection" button to call the "PING_SERVER" service, and pop-up a status message, you'd use code like this:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="jquery.oracle-ucm-1.0.js"></script> <form> <button id="pingServer" name="pingServer">Test Connection</button> </form> <script> $(document).ready(function(){ $("#pingServer").click(function(){ var testData = { IdcService : "PING_SERVER" }; $.ucm.executeService(testData, function(ucmResponse){ var msg = ucmResponse.getValue("StatusMessage"); alert(msg); }); return false; }); }); </script>

Notice how we have to pass function(ucmResponse){} as a parameter to the executeService method... and then fill that function with the code we want to run after the request completes. Also note that we are passing in functions as parameters to the button's click event, and to the document's ready event. Passing around functions in this way looks quite odd if you're used to object-oriented languages like Java... but it's standard operating procedure for jQuery and AJAX.

The ucmResponse object is a standard JSON data object, with the following convenience functions added:

  • getValue('value') looks in the LocalData and the ResultSets to get a value from the response.
  • getRow('resultSetName', index) gets the row in the specific ResultSet at the specific index as an associative array (hashtable) of name-value pairs.
  • findRowIndex('resultSetName', 'column', 'value') returns the first row index in the result set where the column equals the specified value.

There are more examples and instructions in the download. If you have any suggestions or requests, please leave a comment!

Great work.

Great work Bex

Thanks!

You're a fan of jQuery, correct? I'd be curious to know if you have any feature requests...

~~~~You've Made Me So Very Happy~~~~~

I'm currently working on relatively small UCM PoC project where search results need to be dynamically generated via AJAX. I've been thinking of this for last few days; so, few minutes ago googled `stellent ajax jquery`. Guess what, this article appeared as the 3rd in the search results. Unbelievable!
Quickly downloaded and had look. wow! looks like another excellent piece of work with useful examples from you bex!!
Thank You!

UCM Get file

Hello guys , Is JQuerry can get the file content ? . for example get an HTML/doc/text file from UCM and render it in JSP ?

if , so how ? . can you please update ..?

Thanks
Sudarshan

not quite...

The jQuery library is client-side JavaScript. The "get file" service would be no different that a "get file" link that the client can click. If you want to get HTML and display it on a JSP, use the RIDC connector in the CIS bundle.

Executing sub query

Amazing article Bex. Thank you for sharing. Helped me a lot.
Stuck up: I am trying to execute a sub query. It looks something like this -

var temp
var query1="First query";
$.ucm.quickSearch(query, function(ucmResponse) {
//executing the first query gives me a value which I need to execute the second query

var query2="Second query where attr1 is (value retrieved from first)"
$.ucm.quickSearch(query, function(ucmResponse) {
temp="abc";
}
// unable to retrieve the value temp. It says undefined.
}

Understood so far: temp variable out of scope in inner search
Why: unknow

Would be glad if you can help!
Thank you

global vs local

Is "temp" in the global scope? Or is it defined in another function? If it's a local variable, it just won't be in scope. You need to define it in the local scope, or in something else that is in scope... like this:

$.ucm.temp = "abc";

Or, you could use a closure... but explaining how those work is a whole separate blog post ;-)

Execution of search query

Hi Bex,

We are currently working on a requirement and we need to execute the Search.
We pass the query and excute SS_GET_SEARCH_RESULTS and then loop over the resultset to display the search results.
Now there is a requirement where in i need to execute another search which should display the results from the previos result set.

For this we were actually appending the query each time to the original query and execute a search.

This logic works fine in other browsers except in IE6 as the query becomes huge for it to handle.

I want to know if we can execute the query on the Result set(original one
).Is there any other way of implementin this.

Regards,
Vasu

No. of results - 200

Hello Bex,

Thank you for the UCM plugin. Currently, I am facing a situation where the query passed to ucm.executeService() returns only 200 results.

Have edited the parameter resultcount to 500 in the quickSearch function where service GET_SEARCH_RESULTS is called. This is a bit strange as the query should return max of resultcount specified.

Any clue would be really helpful.

Thanks,
Fauzia

what about straight web services?

There's nothing about the jQuery plug-in that would cause this... try doing a search through the standard UCM interface. Can you get 500, or is it maxed out at 200? Also, you can run the same query again by specifying the "StartRow" parameter. Set ResultCount to 200, and for the second request, set StartRow to 201, and you'll get the next "page" of results.

Squid + oracle UCM jquery plugin not working

Hi Bex,

I have implemented oracle UCM jquery plugin for calling custom component to send emails. Everything was working fine. after i implemented squid proxy server for caching. It has stopped working

The cgi path is not accesible from the squid enabled server. It is throwing 403 access forbidden error.

Interestingly , from the same squid enabled server

GET_FILE service provided by content server is working fine but the EMAIL service is failing.

http://wave2rfs/oracleUCM/idcplg?IdcService=GET_FILE -- The content server service is working fine

http://wave2rfs/oracleUCM/idcplg?IdcService=CMS_EMAIL - The custom service for sending emails is failing.

Any clue will be really helpful.

general ajax problem...

This is probably because the AJAX request is trying to go to the back-end UCM server, but the browser thinks it should be only going to the Squid reverse proxy. This is a general AJAX issue, and takes some tuning of your reverse-proxy to make it work right. The GET_FILE is probably working because it's a HTTP GET, whereas the CMS_EMAIL is probably doing a POST... jQuery handles them differently.

jquery 1.4 and json

Bex,
Have you noticed that at times UCM will encode json like so
"datata here the \'single quote\' and more" and jquery 1.4 is much more strict at this and barfs with the ucm return data. It seems that since single quotes are allowed inside of double that is does not like to have it escaped.

Also I have experienced the 200 record limit for the search results, not sure if its possible to change that or not. IT appears you cant go any higher these days.

*sigh*

The whole point about JSON was so that we could be sloppy... grrr...

I was using mostly jQuery 1.2 and 1.3, so I hadn't seen that yet. OK, it's about time for another revision anyway. I'll put something together and post it.

Type head feature for option list in Checkin Page

Hi Bex,

I have been trying to employ the type head functionality on the option list appearing on checkin page such that when user starts typing something then system should load the possible drop down values. These values would definitely be not generating out of any views or something but after querying some custom/OOTB table in the system.

Can I make use of this JQuery Plugin to see this working?

Thanks in Advance
Sam

yes...

Although you'll need a custom service on the back-end to do to type-ahead query... so if somebody types "Ca", you'll need a service that can return a simple list (like Carrot and Cauliflower), and then turn that into a data source that can be consumed by jQuery. My company -- Bezzotech -- has one of these already, if you are interested in purchasing it.

credentials

great stuff. as others I have a question now. how is authentication and authorization handled with this example? who do queries get executed as? we are looking at using some kind of jquery solution to post form data to ucm and create content items based on these submissions but need to do so with a system user or other user. we do not want to pass plain text passwords in trying to do this. does your method require credentials?....thanks.

its all HTTP

If your web server is configured to require credentials for every request, then all AJAX requests will be authenticated. You'll get a prompt. If not, then they will be run as "anonymous." If you use cookie-based auth, then you'll have a problem unless you have a single sign-on-solution that actually works.

IE7 Issue?

Hi Bex:

In IE7 I see the Javascript error: "$.ucm is not or not an object"

This seems to be thrown at the $.ucm.cgiPath = "/idc/idcplg" line. IE8, Firefox, and Chrome all work fine. Is there a quick fix for IE7?

Thanks,
-Greg

probably misformed JSON

I tested my code on IE7 and it worked fine... but usually that kind of error message means that the JSON data somewhere is not being properly parsed by IE7. Usually an extra comma somewhere in the JSON data will make the IE 7 parser choke (although not others) :

http://stackoverflow.com/questions/2439420/ie7-not-digesting-json-parse-error-resolved

This error could be in JSON code anywhere before you include the UCM jQuery plugin...

Enhancement Request: Return subset for resultset

Bex,
Your jQuery plugin has been really helpful. Is there a way to return just a subset of the data in a standard format.

For example, if I have a query and service that returns several Resultsets, and only want to return data from one of the subsets in key:value.

Original data from UCM
{"LocalData": {"refreshSubjects": "","changedSubjects": "","IsJson": "1","refreshSubMonikers": "","dUser": "anonymous","refreshMonikers": "","changedMonikers": "","IdcService": "DCSD_LUNCHMENUS_CALENDAR"},"ResultSets": {"SQLLMCal": {"fields": [{ "name": "SINGLE_ELEMENT" },{ "name": "Start" },{ "name": "SCHOOL_TYPE" },{ "name": "SCHOOL_TYPE_ID" },{ "name": "Title" },{ "name": "ENTRY_SIDE_GROUP" }],"rows": [["141","3/17/11 12:00 AM","Elementary","3","Big Burger","1"],["142","3/17/11 12:00 AM","Elementary","3","Pears","2"]]},"UserAttribInfo": {"fields": [{ "name": "dUserName" },{ "name": "AttributeInfo" }],"rows": [["anonymous","account,web,1,role,guest,15"]]}}}

Just want the SQLLMCal data:
Desired Data
[{"SINGLE_ELEMENT": "141","Start": "3/17/11 12:00 AM","SCHOOL_TYPE": "Elementary","SCHOOL_TYPE_ID": "3","Title": "Big Burger","ENTRY_SIDE_GROUP": "1"},{"SINGLE_ELEMENT": "142","Start": "3/17/11 12:00 AM","SCHOOL_TYPE": "Elementary","SCHOOL_TYPE_ID": "3","Title": "Pears","ENTRY_SIDE_GROUP": "2"}

Thank you,

Ken

Does this work on 11g?

I can't see if this is just 10g or also 11g compatible.

Thanks.

A small query

While developing a connection to ucm via ridc, i am unable to give executeService() method.
Its throwing me a n error stating that executeService() method .
Can u pls let me know what am i missing here

Recent comments