jQuery Post With HDA Payload
In a previous post I covered some examples of using jQuery with Content Server as well as a component to help facilitate testing out some of this functionality. Dan Kozlowski asked in the comments and over here on the Oracle ECM Forums about how he might use jQuery when the INPUT has HDA ResultSet data. He gives the following example:
@Properties LocalData
IdcService=EDIT_USER
dName=jsmith
dFullName=Jennifer Smith
dUserAuthType=Local
dPassword=password
dEmail=jsmith@stellent.com
dUserType=MKT
dUserLocale=English-US
@end
@ResultSet UserAttribInfo
2
dUserName
AttributeInfo
jsmith
role,admin,15,role,contributor,15
@end
There are two magical parts to get this to work. First, you need to set the REQUEST (not response) content type. Second, your payload has to be in a certain format. Let’s look at each of these in turn.
First, here’s a sneak peek of the jQuery AJAX request:
$.ajax(
{
type: “POST”
, contentType: “text/hda; charset=utf-8″
, url: “”
, data: jQuery(“#txtData”).html()
, success: function(msg)
{
alert(msg);
}
, error: function(msg)
{
alert(“Error: ” + msg);
}
});
Notice the contentType setting!
Now, the payload, specified by the variable named data, has to be in a certain format. This format should start with IsJava=1 and be followed by the encoding and finally the first ResultSet known as LocalData. LocalData will contain the IdcService to be called, and a variety of over key/value pairs. At the end of that set we can include additional necessary ResultSets.
I have added an Edit User Sample HCSP for you to download and play with. Check this HCSP into your content server, go to Doc Info and click the web viewable link. The page will load with a text area and a button. Adjust the data in the text area and click submit!
Play around with it some and you should see how this all works together!
Dan, thanks for what turned out to be a fun puzzle.