<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WebCenter Interaction, ALUI, Plumtree blog by Integryst &#187; Code Samples</title>
	<atom:link href="http://blog.integryst.com/webcenter-interaction/tag/code-samples/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.integryst.com/webcenter-interaction</link>
	<description>WebCenter Interaction, ALUI, Plumtree</description>
	<lastBuildDate>Thu, 12 Jan 2012 22:54:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Bug Blog 13: Fix Broken File Downloads in 10gR3 (Part Quatre)</title>
		<link>http://blog.integryst.com/webcenter-interaction/2011/10/25/bug-blog-13-fix-broken-file-downloads-in-10gr3-part-quatre/</link>
		<comments>http://blog.integryst.com/webcenter-interaction/2011/10/25/bug-blog-13-fix-broken-file-downloads-in-10gr3-part-quatre/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 14:56:23 +0000</pubDate>
		<dc:creator>Matt Chiste</dc:creator>
				<category><![CDATA[Bug]]></category>
		<category><![CDATA[Coding Tricks]]></category>
		<category><![CDATA[Knowledge Directory]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Experience Definition]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.integryst.com/webcenter-interaction/?p=1385</guid>
		<description><![CDATA[When WebCenter Interaction 10gR3 was released, it was a complete train wreck for documents in the Knowledge Directory &#8211; the content headers were wrong, docs wouldn&#8217;t download in Internet Explorer due to the comical back-asswards Javascript file open mechanism, and links couldn&#8217;t be copied or viewed because the anchor tags were malformed. In our last [...]]]></description>
			<content:encoded><![CDATA[<p>When WebCenter Interaction 10gR3 was released, it was a complete train wreck for documents in the Knowledge Directory &#8211; the <a href="http://blog.integryst.com/webcenter-interaction/2010/04/29/bug-blog-3-fix-broken-file-downloads-in-10gr3/">content headers were wrong</a>, <a href="http://blog.integryst.com/webcenter-interaction/2010/05/03/bug-blog-4-fix-broken-file-downloads-in-10gr3-part-duex/">docs wouldn&#8217;t download in Internet Explorer</a> due to the comical back-asswards Javascript file open mechanism, and links couldn&#8217;t be copied or viewed because the <a href="http://blog.integryst.com/webcenter-interaction/2010/06/20/bug-blog-6-fix-broken-file-downloads-in-10gr3-part-trois/">anchor tags were malformed</a>.</p>
<p>In our <a href="http://blog.integryst.com/webcenter-interaction/2010/06/20/bug-blog-6-fix-broken-file-downloads-in-10gr3-part-trois/">last post</a> in this <a href="http://blog.integryst.com/webcenter-interaction/tag/knowledge-directory/">painful series</a>, I shared some code that will resolve the ALUI / WCI Knowledge Directory links so that users can right-click and copy the links, and the files open as expected when clicked.</p>
<p>Since then, I&#8217;ve found that when an admin is in EDIT mode in the Knowledge Directory, the link calamity continues, and a completely different and incomprehensible linking mechanism is used.  So for your reading pleasure today, I&#8217;ll update that post to handle edit mode as well as browse mode.  Again, just add the following HTML to the footer used in your Knowledge Directory (depending on <a href="http://blog.integryst.com/webcenter-interaction/tag/experience-definition/">Experience Definition</a>, there may be more than one):<br />
<span id="more-1385"></span>
<pre class="brush: javascript">
&lt;META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; charset=UTF-8&quot;&gt;
&lt;pcs:value expr=&quot;text&quot;&gt;&lt;/pcs:value&gt;

&lt;pt:common.transformer pt:fixurl=&quot;off&quot; xmlns:pt=&#039;http://www.plumtree.com/xmlschemas/ptui/&#039;/&gt;
&lt;script&gt;
try
{
       // KD BROWSE Mode
       // &lt;a href=&quot;#&quot; onclick=&quot;var currentWin = PTCommonOpener.openInNewWindow (&#039;&#039;, &#039;Opener_18_1214986&#039;, 800, 600, true); currentWin.location= &#039;http://portal.integryst.com/portal/server.pt /document/1214936/DocName&#039;; return false;&quot;&gt;DocName&lt;/a&gt;
       if (document.title==&quot;Directory&quot;)
       {
              // get all links
              var anchors = document.links;
              for (x=0; x&lt;anchors.length; x++) {

                     // get only those with an onclick event
                     onclickJS = anchors[x].onclick;
                     if (onclickJS != null)
                     {
                           onclickJS = &quot;&quot; + onclickJS;
                           var locCommonOpener = onclickJS.indexOf(&quot;PTCommonOpener.openInNewWindow&quot;);
                           var locpos = onclickJS.indexOf(&quot;currentWin.location&quot;);

                           // only process links that have the broken PTCommonOpener.openInNewWindow
                           if ((locpos&gt;=0) &amp;amp;amp;&amp;amp;amp; (locCommonOpener&gt;=0))
                           {
                                  // extract the URL from the broken onclick function
                                  var url = onclickJS.substr(locpos);
                                  var locstart = url.indexOf(&quot;&#039;&quot;);
                                  if (locstart&gt;=0)
                                  {
                                         url = url.substr(locstart+1);
                                         var locend = url.indexOf(&quot;&#039;&quot;);
                                         if (locend&gt;=0)
                                         {
                                                // update the URL by clearing the onclick and setting the URL to open in a new window
                                                url = url.substring(0,locend);
                                                anchors[x].href=url;
                                                anchors[x].target=&quot;_new&quot;;
                                                anchors[x].onclick=null;
                                         }
                                  }
                           }
                     }
              }
       }

       // KD Edit Mode
       // &lt;a href=&quot;#&quot; onclick=&quot;var currentWin = PTCommonOpener.openInNewWindow (&#039;&#039;, &#039;Opener_18_1214986&#039;, 800, 600, true); currentWin.location = PTCommonOpener.getOpenerURLOpenObjID (18, 1214926, &#039;&#039;, 2); return false;&quot;&gt; DocName &lt;/a&gt;
       if (document.title==&quot;Edit Directory&quot;)
       {
              // get all links
              var anchors = document.links;
              for (x=0; x&lt;anchors.length; x++) {

                     // get only those with an onclick event
                     onclickJS = anchors[x].onclick;
                     if (onclickJS != null)
                     {
                           onclickJS = &quot;&quot; + onclickJS;
                           var locCommonOpener = onclickJS.indexOf(&quot;PTCommonOpener.openInNewWindow&quot;);
                           var locpos = onclickJS.indexOf(&quot;currentWin.location&quot;);

                           // only process links that have the broken PTCommonOpener.openInNewWindow
                           if ((locpos&gt;=0) &amp;amp;amp;&amp;amp;amp; (locCommonOpener&gt;=0))
                           {
                                  // extract the URL from the broken onclick function
                                  var url = onclickJS.substr(locpos);
                                  var locstart = url.indexOf(&quot;=&quot;);
                                  if (locstart&gt;=0)
                                  {
                                         url = url.substr(locstart+1);
                                         var locend = url.indexOf(&quot;;&quot;);
                                         if (locend&gt;=0)
                                         {
                                                // update the URL by clearing the onclick and setting the URL to open in a new window
                                                url = url.substring(0,locend+1);
                                                anchors[x].href=eval(url);
                                                anchors[x].target=&quot;_new&quot;;
                                                anchors[x].onclick=null;
                                         }
                                  }
                           }
                     }
              }
       }
}
catch (err)
{
       // ignore errors
}
&lt;/script&gt;
</pre>
<p>On a completely unrelated note, thanks to my wonderful numbering scheme of these posts, I can now <a href="http://french.about.com/od/vocabulary/ss/numbers.htm">count to four in French</a>&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.integryst.com/webcenter-interaction/2011/10/25/bug-blog-13-fix-broken-file-downloads-in-10gr3-part-quatre/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Portal API Search Sample Code: IPTSearchRequest</title>
		<link>http://blog.integryst.com/webcenter-interaction/2011/06/14/portal-api-search-for-all-objects-in-a-folder/</link>
		<comments>http://blog.integryst.com/webcenter-interaction/2011/06/14/portal-api-search-for-all-objects-in-a-folder/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 11:17:02 +0000</pubDate>
		<dc:creator>Matt Chiste</dc:creator>
				<category><![CDATA[Coding Tricks]]></category>
		<category><![CDATA[Search Server]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[LockDown]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://blog.integryst.com/webcenter-interaction/?p=1141</guid>
		<description><![CDATA[Today&#8217;s post is a quick code snippet from Integryst&#8217;s LockDown product (which relies heavily on search to identify objects for reporting on security configurations), and provides a pretty good sample of how to search for objects in the Plumtree / ALUI / WebCenter portal using the Search APIs. Hope you find it helpful! See the [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s post is a quick code snippet from Integryst&#8217;s <a href="http://www.integryst.com/site/integryst.i/page/products/204/lockdown/471">LockDown</a> product (which relies heavily on search to identify objects for reporting on security configurations), and provides a pretty good sample of how to search for objects in the Plumtree / ALUI / WebCenter portal using the Search APIs.  Hope you find it helpful!</p>
<p>See the docs for <a href="http://download.oracle.com/docs/cd/E13158_01/alui/wci/docs103/uiguide/apidocs/java/portalserver/com/plumtree/server/IPTSearchRequest.html" target=_new>IPTSearchRequest</a> and <a href="http://download.oracle.com/docs/cd/E13158_01/alui/wci/docs103/uiguide/apidocs/java/portalserver/com/plumtree/server/PT_SEARCH_SETTING.html" target=_new>PT_SEARCH_SETTING</a> for more options in developing your own search killer app.</p>
<pre class="brush: csharp">
// get the folder ID to load the grid data
string searchQuery = Request.Params[&quot;query&quot;];

if (searchQuery == null)
return; // do nothing if there&#039;s no query

ArrayList userGroupResults = new ArrayList();
int classid, objectid;
string classname, objectname;

// get the portal session from the HTTPSession
PortalSessionManager sessionManager = PortalSessionFactory.getPortalSessionManager(Session, Request, Response);
IPTSession ptSession = sessionManager.getAPISession();

//search for users and groups that match this query
IPTSearchRequest request = ptSession.GetSearchRequest();

//turn off requests for collab/content apps
request.SetSettings(PT_SEARCH_SETTING.PT_SEARCHSETTING_APPS, PT_SEARCH_APPS.PT_SEARCH_APPS_PORTAL);

// Restrict the search to users and groups
request.SetSettings(PT_SEARCH_SETTING.PT_SEARCHSETTING_OBJTYPES, new int[] {PT_CLASSIDS.PT_USER_ID, PT_CLASSIDS.PT_USERGROUP_ID});

// Restrict the search to specific folders
request.SetSettings( PT_SEARCH_SETTING.PT_SEARCHSETTING_DDFOLDERS, objectFolder);
request.SetSettings( PT_SEARCH_SETTING.PT_SEARCHSETTING_INCLUDE_SUBFOLDERS, 1);

// make sure the appropriate fields are returned.
request.SetSettings(PT_SEARCH_SETTING.PT_SEARCHSETTING_RET_PROPS, new int[] {
	PT_PROPIDS.PT_PROPID_OBJECTID,
	PT_PROPIDS.PT_PROPID_CLASSID
});

// set search order
request.SetSettings(PT_SEARCH_SETTING.PT_SEARCHSETTING_ORDERBY, PT_PROPIDS.PT_PROPID_CLASSID);
IPTSearchQuery query = request.CreateBasicQuery(searchQuery + &quot;*&quot;, &quot;PT&quot; + PT_INTRINSICS.PT_PROPERTY_OBJECTNAME);

IPTSearchResponse results = request.Search(query);

UserGroupObject tempRes;
int numUsersGroupsFound = 0;

// iterate the results
for (int x = 0; x &lt; results.GetResultsReturned(); x++)
{
	objectname = results.GetFieldsAsString(x, PT_INTRINSICS.PT_PROPERTY_OBJECTNAME);
	objectid = results.GetFieldsAsInt(x, PT_INTRINSICS.PT_PROPERTY_OBJECTID);
	classid = results.GetFieldsAsInt(x, PT_INTRINSICS.PT_PROPERTY_CLASSID);
	classname = GenericObject.getClassNameFromID(classid);

	// search filter doesn&#039;t seem to work; make sure the classid is user or group
	if ((classid == PT_CLASSIDS.PT_USER_ID) || (classid == PT_CLASSIDS.PT_USERGROUP_ID))
	{
		// do stuff
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.integryst.com/webcenter-interaction/2011/06/14/portal-api-search-for-all-objects-in-a-folder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Treat Collaboration Server as a REST-based API</title>
		<link>http://blog.integryst.com/webcenter-interaction/2010/08/05/treat-collaboration-server-as-a-rest-based-api/</link>
		<comments>http://blog.integryst.com/webcenter-interaction/2010/08/05/treat-collaboration-server-as-a-rest-based-api/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 16:16:56 +0000</pubDate>
		<dc:creator>Matt Chiste</dc:creator>
				<category><![CDATA[Coding Tricks]]></category>
		<category><![CDATA[Collaboration Server]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Collaboration]]></category>
		<category><![CDATA[hack]]></category>

		<guid isPermaLink="false">http://blog.integryst.com/webcenter-interaction/?p=552</guid>
		<description><![CDATA[The IDK methods for Collaboration Server are terribly sparse &#8211; you can&#8217;t get calendar events, file sizes, or a whole bunch of other critical data that you may want if you were to actually embark on a mission to write a better UI for Collab (trust me, I have).  Sure you could try and use [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://download.oracle.com/docs/cd/E13158_01/alui/wci/docs103/devguide/con_prc_collaboration.html" target="_blank">IDK methods for Collaboration Server </a>are terribly sparse &#8211; you can&#8217;t get calendar events, file sizes, or a whole bunch of other critical data that you may want if you were to actually embark on a mission to write a better UI for Collab (trust me, I have).  Sure you could try and use the woefully undocumented Collab API &#8211; I&#8217;ve shown you how to <a href="http://blog.integryst.com/webcenter-interaction/2010/07/05/deploying-wci-api-applications-without-the-portal-installed" target="_self">deploy the portal API</a> in the past &#8211; but that&#8217;s a challenge in and of itself.</p>
<p>Instead, let&#8217;s look at an alternate approach:  use the Collab Server as a sort of <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer" target="_blank">REST API</a>.  It&#8217;s not really, but the basic idea is that you use URLs in your code to directly call functionality in Collaboration Server to do certain tasks.  For example, say you want to add a Collaboration project to a page programmatically; there is no mechanism to do this through the IDK, and we have no idea how to use the API, but using a <a href="http://blog.integryst.com/webcenter-interaction/2010/08/02/cool-tools-8-iewatch" target="_self">header tool</a>, we find that through Project Explorer, it works with a simple URL: <strong>/collab/do/project/selector/add?commPage=true&amp;projID=COLLABID</strong>.</p>
<p>So, it turns out we can do the same thing programmatically, by using Java&#8217;s network libraries to call that URL directly (setting the proper authenticationid).  The code after the jump shows an example of how to do this; we use this approach in <a href="http://www.integryst.com/site/integryst.i/page/products/204/automater/466" target="_self">Integryst&#8217;s Automater</a>, which allows you to script a bunch of actions at a time (what good is automatically creating a collab project if you can&#8217;t add it to a community page you just created!?). </p>
<p>Tweak away!</p>
<p><span id="more-552"></span></p>
<pre class="brush: java">
int collabID = ParamHelper.getIntParamValue(getInputs(),&quot;collabid&quot;,-1);
int communityID = ParamHelper.getIntParamValue(getInputs(),&quot;communityid&quot;,-1);
String wsapi = ParamHelper.getParamValue(getInputs(),&quot;wsapi&quot;);

String response = &quot;&quot;;

LOG.info(&quot;&gt; Add Collab Project to Community. Params [collabID=&quot; + collabID + &quot;, communityID=&quot; + communityID + &quot;]&quot;);

// the IDK doesn&#039;t provide methods for attaching messages to documents, so we use HTTP methods to do that
// collab settings for direct connection
String host = ParamHelper.getParamValue(getInputs(),&quot;collab.host&quot;);
String port = ParamHelper.getParamValue(getInputs(),&quot;collab.port&quot;);
String user = ParamHelper.getParamValue(getInputs(),&quot;collab.user&quot;);
String pass= ParamHelper.getParamValue(getInputs(),&quot;collab.pass&quot;);

// these may not be needed...
String imageserver = ParamHelper.getParamValue(getInputs(),&quot;collab.imageserverurl&quot;);
String gadgetid = ParamHelper.getParamValue(getInputs(),&quot;collab.gadgetid&quot;);
String pageid = ParamHelper.getParamValue(getInputs(),&quot;collab.pageid&quot;);
String userid = ParamHelper.getParamValue(getInputs(),&quot;collab.userid&quot;);
String username = ParamHelper.getParamValue(getInputs(),&quot;collab.username&quot;);

String addr = &quot;http://&quot; + host + &quot;:&quot; + port + &quot;/collab/do/project/selector/add?commPage=true&amp;amp;amp;amp;amp;projID=&quot; + collabID;

try{
LOG.debug(&quot;Attempting Collab Connection to &quot; + addr);
URL url = new URL(addr);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
String encoding = new sun.misc.BASE64Encoder().encode((user + &quot;:&quot; + pass).getBytes());
conn.setRequestProperty (&quot;Authorization&quot;, &quot;Basic &quot; + encoding);
conn.setRequestProperty (&quot;CSP-Aggregation-Mode&quot;, &quot;Multiple&quot;);
conn.setRequestProperty (&quot;CSP-Activity-Rights&quot;, &quot;uri%u003A%u002F%u002Furi%u002Ecollaboration %u002Eplumtree%u002Ecom%u002Factivity%u002Fviewpresence,uri%u003A%u002F %u002Furi%u002Ecollaboration %u002Eplumtree%u002Ecom %u002Factivity%u002Fbulkupload,uri%u003A %u002F%u002Furi%u002Ecollaboration%u002Eplumtree%u002Ecom%u002Factivity %u002Fmanagecollab,uri%u003A%u002F%u002Furi %u002Ecollaboration %u002Eplumtree%u002Ecom%u002Factivity %u002Fmanagecollabprojects&quot;);
conn.setRequestProperty (&quot;CSP-Gateway-Specific-Config&quot;,
&quot;PT-User-Name=&quot; + username + &quot;,&quot; +
&quot;PT-User-ID=&quot; + userid + &quot;,&quot; +
&quot;PT-Community-ID=&quot; + communityID + &quot;,&quot; +
&quot;PT-Gadget-ID=&quot; + gadgetid + &quot;,&quot; +
&quot;PT-Gateway-Version=2.5,&quot; +
&quot;PT-Content-Mode=1,&quot; +
&quot;PT-Time-Zone=America%u002FNew%u005FYork,&quot; +
&quot;PT-Imageserver-URI=&quot; + imageserver + &quot;/,&quot; +
&quot;PT-User-Charset=UTF-8,&quot; +
&quot;PT-Page-ID=&quot; + pageid + &quot;,&quot; +
&quot;PT-Community-ACL=15,&quot; +
&quot;PT-SOAP-API-URI=&quot; + wsapi + &quot;,&quot; +
&quot;PT-Class-ID=43,&quot; +
&quot;PT-Guest-User=0&quot;);

conn.setRequestProperty (&quot;USER-AGENT&quot;, &quot;Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2)&quot;);
conn.setRequestProperty (&quot;CSP-Gateway-Type&quot;, &quot;Plumtree&quot;);
conn.setRequestProperty (&quot;CSP-User-Info&quot;, &quot;FullName=&quot; + username);
conn.setRequestProperty (&quot;CSP-Protocol-Version&quot;, &quot;1.3&quot;);
conn.setRequestProperty (&quot;Accept-Language&quot;, &quot;en-us&quot;);
conn.setRequestProperty (&quot;CSP-Can-Set&quot;, &quot;Gadget-User,User,Gadget-Realm,Realm&quot;);
conn.setRequestProperty (&quot;Host&quot;, host + &quot;:&quot; + port);
conn.setRequestProperty (&quot;ACCEPT&quot;, &quot;*/*&quot;);
conn.setRequestProperty (&quot;Accept-Encoding&quot;, &quot;gzip&quot;);
conn.setRequestMethod(&quot;GET&quot;);

conn.connect();

// read the headers
for (int i=0; ; i++) {
String headerName = conn.getHeaderFieldKey(i);
String headerValue = conn.getHeaderField(i);

if (headerName == null &amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp; headerValue == null) {
// No more headers
break;
}
if (headerName == null)
LOG.debug(&quot;Response: &quot; + headerValue);
else
LOG.debug(&quot;Response Header: &quot; + headerName + &quot;: &quot; + headerValue);
}

InputStream in = conn.getInputStream();

// read the response
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String text = reader.readLine();
if (text != null)
LOG.debug(&quot;Response Text: &quot; + text);

response += &quot;Project &quot; + collabID + &quot; has been added to community : &quot; + communityID + &quot;
&quot;;

conn.disconnect();
}
catch(Exception ex) {
response = &quot;Exception adding project &quot; + collabID + &quot; to community &quot; + communityID + &quot;: &quot; + ex.getMessage();
LOG.error(response, ex);
}

addOutput(new Param(&quot;collabid&quot;, &quot;&quot; + collabID, &quot;output&quot;, null));
addOutput(new Param(&quot;communityid&quot;, &quot;&quot; + communityID, &quot;output&quot;, null));

LOG.info(&quot;&lt; Add Collab Project to Community: &quot; + response);
return response;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.integryst.com/webcenter-interaction/2010/08/05/treat-collaboration-server-as-a-rest-based-api/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bug Blog 6: Fix Broken File Downloads in 10gR3 (Part Trois)</title>
		<link>http://blog.integryst.com/webcenter-interaction/2010/06/20/bug-blog-6-fix-broken-file-downloads-in-10gr3-part-trois/</link>
		<comments>http://blog.integryst.com/webcenter-interaction/2010/06/20/bug-blog-6-fix-broken-file-downloads-in-10gr3-part-trois/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 13:03:22 +0000</pubDate>
		<dc:creator>Matt Chiste</dc:creator>
				<category><![CDATA[Bug]]></category>
		<category><![CDATA[Coding Tricks]]></category>
		<category><![CDATA[Knowledge Directory]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.integryst.com/webcenter-interaction/?p=481</guid>
		<description><![CDATA[*sigh*.  You&#8217;ve upgraded from ALUI to WCI 10gR3, and your Knowledge Directory links got all screwed up, didn&#8217;t they?  HTML files now throw an open/save dialog, some documents don&#8217;t open, you can&#8217;t copy links by just right-clicking them and choosing &#8220;Copy Shortcut&#8221;, and IE throws a popup blocker when you click a link in the Knowledge [...]]]></description>
			<content:encoded><![CDATA[<p><strong>*sigh*.</strong>  You&#8217;ve upgraded from ALUI to WCI 10gR3, and your Knowledge Directory links got all screwed up, didn&#8217;t they?  HTML files now throw an open/save dialog, some documents don&#8217;t open, you can&#8217;t copy links by just right-clicking them and choosing &#8220;Copy Shortcut&#8221;, and IE throws a popup blocker when you click a link in the Knowledge Directory, doesn&#8217;t it? </p>
<p><a href="http://blog.integryst.com/webcenter-interaction/files/2010/06/wci-knowledge-directory-js.png"><img class="alignnone size-full wp-image-482" title="wci-knowledge-directory-js" src="http://blog.integryst.com/webcenter-interaction/files/2010/06/wci-knowledge-directory-js.png" alt="" width="666" height="201" /></a></p>
<p>You got the &#8220;To help protect your security, Internet Explorer blocked this site from downloading files to your computer&#8221; blues, huh?</p>
<p>I&#8217;ve <a href="http://blog.integryst.com/webcenter-interaction/2010/04/29/bug-blog-3-fix-broken-file-downloads-in-10gr3/" target="_self">tried creating a Plumtree Filter</a>, and that worked pretty well, but not quite enough.</p>
<p>I&#8217;ve <a href="http://blog.integryst.com/webcenter-interaction/2010/05/03/bug-blog-4-fix-broken-file-downloads-in-10gr3-part-duex/" target="_self">tried tweaking the Portal&#8217;s Javascript files</a>, and THAT worked pretty well, but again, not quite well enough.</p>
<p>So, today, my friend&#8217;s, third time&#8217;s a charm:  rather than trying to fix this on the server side, we&#8217;re going to knock out this issue once and for all on the client side.  Check out those previous blog entries for a more detailed description of the problem, but basically, it&#8217;s because the portal uses a crazy convoluted way of opening documents via javascript. </p>
<p>What we&#8217;re going to do today is stick some javascript in the footer of the page.  This JavaScript is going to simply find all those back-asswards links and replace them with NORMAL &lt;a href=xxx target=_new&gt; links.  If you add it to the footer of your site (specifically, the footer used for the KD, but the code is smart enough not to do anything if it&#8217;s on all pages), it should be able to take care of the rest.  Just make sure you add it to the Presentation Template and not the Content Item, because you-know-who only knows what a <a href="http://blog.integryst.com/webcenter-interaction/category/publisher/" target="_self">mess the out-of-the-box rich text editor is</a> with javascript and adaptive tags.</p>
<p>The code after the break should be self-explanatory, but as always, if you&#8217;ve got a question or comment, feel free to post it here.  Also note that this code only fixes the download links; it doesn&#8217;t kill that &#8220;Open/Save&#8221; dialog box for things like HTML files.  For that you&#8217;ll still need the <a href="http://blog.integryst.com/webcenter-interaction/2010/04/29/bug-blog-3-fix-broken-file-downloads-in-10gr3/" target="_self">Plumtree Filter</a>.<span id="more-481"></span>
<pre class="brush: javascript">

&lt;pt:common.transformer pt:fixurl=&quot;off&quot; xmlns:pt=&#039;http://www.plumtree.com/xmlschemas/ptui/&#039;/&gt;
&lt;script&gt;
try
{
       // only run in the KD
       if (document.title==&quot;Directory&quot;)
       {
              // get all links
              var anchors = document.links;
              for (x=0; x&lt;anchors.length; x++) {

                     // get only those with an onclick event
                     onclickJS = anchors[x].onclick;
                     if (onclickJS != null)
                     {
                           onclickJS = &quot;&quot; + onclickJS;
                           var locCommonOpener = onclickJS.indexOf(&quot;PTCommonOpener.openInNewWindow&quot;);
                           var locpos = onclickJS.indexOf(&quot;currentWin.location&quot;);

                           // only process links that have the broken PTCommonOpener.openInNewWindow
                           if ((locpos&gt;=0) &amp;amp; &amp;amp; (locCommonOpener&gt;=0))
                           {
                                  // extract the URL from the broken onclick function
                                  var url = onclickJS.substr(locpos);
                                  var locstart = url.indexOf(&quot;&#039;&quot;);
                                  if (locstart&gt;=0)
                                  {
                                         url = url.substr(locstart+1);
                                         var locend = url.indexOf(&quot;&#039;&quot;);
                                         if (locend&gt;=0)
                                         {
                                                // update the URL by clearing the onclick and setting the URL to open in a new window
                                                url = url.substring(0,locend);
                                                anchors[x].href=url;
                                                anchors[x].target=&quot;_new&quot;;
                                                anchors[x].onclick=null;
                                         }
                                  }
                           }
                     }
              }
       }
}
catch (err)
{
       // ignore errors
}
&lt;/script&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.integryst.com/webcenter-interaction/2010/06/20/bug-blog-6-fix-broken-file-downloads-in-10gr3-part-trois/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bug Blog 4: Fix Broken File Downloads in 10gR3 (Part Deux)</title>
		<link>http://blog.integryst.com/webcenter-interaction/2010/05/03/bug-blog-4-fix-broken-file-downloads-in-10gr3-part-duex/</link>
		<comments>http://blog.integryst.com/webcenter-interaction/2010/05/03/bug-blog-4-fix-broken-file-downloads-in-10gr3-part-duex/#comments</comments>
		<pubDate>Mon, 03 May 2010 06:12:05 +0000</pubDate>
		<dc:creator>Matt Chiste</dc:creator>
				<category><![CDATA[Bug]]></category>
		<category><![CDATA[Coding Tricks]]></category>
		<category><![CDATA[Knowledge Directory]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.integryst.com/webcenter-interaction/?p=344</guid>
		<description><![CDATA[Last week I provided portal filter code to fix some elements of opening documents in WebCenter Interaction&#8217;s Knowledge Directory (and Search and Snapshot Queries).  This week is another follow-up on that theme, and I&#8217;ll provide another piece of code to continue cleaning up the mess that is the Knowledge Directory Downloading Clusterf*ck (in IE at least). Ever gotten [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I provided <a href="http://blog.integryst.com/webcenter-interaction/2010/04/29/bug-blog-3-fix…loads-in-10gr3/" target="_self">portal filter code</a> to fix some elements of opening documents in WebCenter Interaction&#8217;s Knowledge Directory (and Search and Snapshot Queries).  This week is another follow-up on that theme, and I&#8217;ll provide another piece of code to continue cleaning up the mess that is the Knowledge Directory Downloading Clusterf*ck (in IE at least).</p>
<p>Ever gotten this little present after doing an upgrade to 10gR3, when trying to open a document in the Knowledge Directory using IE7 or IE8?</p>
<p> <a href="http://blog.integryst.com/webcenter-interaction/files/2010/05/wci-ie-blocked-download.png"><img class="alignnone size-full wp-image-348" title="wci-ie-blocked-download" src="http://blog.integryst.com/webcenter-interaction/files/2010/05/wci-ie-blocked-download.png" alt="" width="496" height="176" /></a></p>
<p>Ah, the old &#8220;To help protect your security, Internet Explorer blocked this site from downloading files to your computer.&#8221;  What&#8217;s even more ridiculous, if you &#8220;accept&#8221; the download, it STILL doesn&#8217;t work because IE tries to reload the page, and WCI is very stupid about how it opens this popup window (see how that address bar shows &#8220;about:blank&#8221;?).  It seems this only happens in IE, and only if you have adaptive layouts disabled with &#8220;open documents in new window&#8221; enabled, so it doesn&#8217;t affect everyone.  But I die a little on the inside every time I see that stupid thing: yes, my friends, I am an empty, hollow shell of a consultant.</p>
<p>Fortunately, I decided to seek redemption for WCI and myself by proxy, and checked out the HTML source for a typical file open link.  It&#8217;s kinda hilarious:</p>
<pre class="brush: html">

&lt;a href=&quot;#&quot; onclick=&quot;var currentWin = PTCommonOpener.openInNewWindow(&#039;&#039;, &#039;Opener_18_1322446&#039;, 800, 600, true); currentWin.location= &#039;http://server/portal/server.pt/document/1322446/slide_1&#039;; return false;&quot;&gt;Doc Name&lt;/a&gt;
</pre>
<p>Whhaaaaaaa&#8230;!?  Sure I know there are dozens of ways you can open a document in a popup window, and many have their advantages (for example, by using JavaScript you can control the size and layout of the window), but I&#8217;d be hard-pressed to come up with a worse way to open a document.  I&#8217;ve always hated the fact that you can&#8217;t just hover over the link to see the URL, and can&#8217;t right-click and copy the shortcut to mail to someone later. (Tip: use adaptive layouts and these problems go away!).  Or they could have at least just done a window.open method in that onclick event.  OK, so they wanted to use a wrapper method &#8211; that&#8217;s fine &#8211; but the PTCommonOpener.openInNewWindow actually takes a URL paramater, so they could have just passed the URL into that function, rather than creating a new, EMPTY document and then trying to use Javascript to load the document into that window.  At very least they could have put the document URL in the &#8220;href&#8221; parameter so it&#8217;d work without JavaScript (and be <a href="http://www.section508.gov/" target="_blank">508-compliant</a>) and users could copy the links with a simple right-click.</p>
<p>OK enough rambling.  On to a solution:<span id="more-344"></span></p>
<p>It&#8217;s clear looking at the above code that while Microsoft&#8217;s security controls can sometimes be oppressive, this blocked transfer kinda makes sense:  IE blocks downloads that <a href="http://msdn.microsoft.com/en-us/library/dd565669(VS.85).aspx" target="_blank">weren&#8217;t initiated by the user</a> (i.e., were initiated by JavaScript).  The problem is, given the brain-dead way that documents are opened in a new window (by creating an EMPTY window first, then trying to download the document later), when you accept the download, the browser reloads the about:blank() page instead of the actual file.</p>
<p>Using a <a href="http://blog.integryst.com/webcenter-interaction/2010/04/21/cool-tools-5-net-decompilers/" target="_self">.NET decompiler</a> (I used dis# because I needed to search the entire portaluiinfrastructure.dll for the text string &#8220;openInNewWindow&#8221;), I found the code in com.plumtree.portaluiinfrastructure.opener.PTOpenerLinks:</p>
<pre class="brush: csharp">

public static string GetJSOpenInNewWindow(string _strURL, string _strWindowName, string _strWindowWidth, string _strWindowHeight, bool _bIsWindowFancy)
        {
            com.plumtree.openfoundation.util.XPStringBuilder sbOpenerJS = new com.plumtree.openfoundation.util.XPStringBuilder(300);
            sbOpenerJS.Append(&quot;var currentWin = &quot;);
            sbOpenerJS.Append(&quot;PTCommonOpener.openInNewWindow&quot;);
            sbOpenerJS.Append(&quot;(&#039;&#039;, &#039;&quot;);
            sbOpenerJS.Append(_strWindowName).Append(&quot;&#039;, &quot;);
            sbOpenerJS.Append().Append(&quot;, &quot;);
            sbOpenerJS.Append(_strWindowHeight).Append(&quot;, &quot;);
            sbOpenerJS.Append(_bIsWindowFancy);_strWindowWidth
            sbOpenerJS.Append(&quot;);&quot;);
            sbOpenerJS.Append(&quot;currentWin.location=&quot;).Append(_strURL);
            return sbOpenerJS.ToString();
        }
</pre>
<p>Ideally, I&#8217;d change the code to something like this:</p>
<pre class="brush: csharp">

public static string GetJSOpenInNewWindow(string _strURL, string _strWindowName, string _strWindowWidth, string _strWindowHeight, bool _bIsWindowFancy)
        {
            com.plumtree.openfoundation.util.XPStringBuilder sbOpenerJS = new com.plumtree.openfoundation.util.XPStringBuilder(300);
            sbOpenerJS.Append(&quot;var currentWin = &quot;);
            sbOpenerJS.Append(&quot;PTCommonOpener.openInNewWindow&quot;);
            sbOpenerJS.Append(&quot;(&#039;&quot;);
            sbOpenerJS.Append(_strURL);
            sbOpenerJS.Append(&quot;&#039;, &#039;&quot;);
            sbOpenerJS.Append(_strWindowName).Append(&quot;&#039;, &quot;);
            sbOpenerJS.Append().Append(&quot;, &quot;);
            sbOpenerJS.Append(_strWindowHeight).Append(&quot;, &quot;);
            sbOpenerJS.Append(_bIsWindowFancy);_strWindowWidth
            sbOpenerJS.Append(&quot;);&quot;);
            return sbOpenerJS.ToString();
        }
</pre>
<p>(or even better, figure out how to change this to a normal link like &lt;a href=&#8221;http://url&#8221; target=_new&gt;docname&lt;/a&gt;)</p>
<p>&#8230; but recompiling decompiled code &#8211; especially in a .NET library as large as portaluiinfrastructure &#8211; well, that just wasn&#8217;t going to happen.</p>
<p>So we can&#8217;t change the HTML that generates this terrible link, but is there at least a way to fix the problem where we can get the browser to open the link in a new window in one step instead of two?  Fortunately, the answer is yes.  I&#8217;ll leave the analysis of this hack to you, but basically it creates a global object and allows both of those calls (open the window and set the URL) to be made before actually calling the open window method.</p>
<p>Open the PTHOME\imageserver\plumtree\portal\private\js\ptcommonopener.js file and change:</p>
<pre class="brush: javascript">

PTCommonOpener.openInNewWindow = function(_strURL, _strWindowName, _strWidth, _strHeight, _bIsFancyWindow)
{
 return PTCommonOpener.JSUTIL_VERSIONOBJ.PTWindowUtil.openWindow(_strURL, _strWindowName, _strHeight, _strWidth, _bIsFancyWindow);
}
</pre>
<p>&#8230; to:</p>
<pre class="brush: javascript">

var newwin = {location:&#039;&#039;, _strWindowName:&#039;&#039;, _strWidth:&#039;&#039;, _strHeight:&#039;&#039;, _bIsFancyWindow:&#039;&#039;};
PTCommonOpener.handlePopup = function() {
 PTCommonOpener.JSUTIL_VERSIONOBJ.PTWindowUtil.openWindow(newwin.location, newwin._strWindowName, newwin._strHeight, newwin._strWidth, newwin._bIsFancyWindow);
}

PTCommonOpener.openInNewWindow = function(_strURL, _strWindowName, _strWidth, _strHeight, _bIsFancyWindow)
{
 if (_strURL != &quot;&quot;)
  return PTCommonOpener.JSUTIL_VERSIONOBJ.PTWindowUtil.openWindow(_strURL, _strWindowName, _strHeight, _strWidth, _bIsFancyWindow);

 newwin.location=_strURL;
 newwin._strWindowName=_strWindowName;
 newwin._strWidth=_strWidth;
 newwin._strHeight=_strHeight;
 newwin._bIsFancyWindow=_bIsFancyWindow;
 window.setTimeout(&quot;PTCommonOpener.handlePopup();&quot;,50);
 return newwin;
}
</pre>
<p><strong>Update 7/17/2010</strong>: Thanks to Joel Collins for helping out with some of the code here and building the solution&#8217;s binaries!  Hopefully you find them useful so you can just deploy the .DLL without having to compile it yourself.  Download <a href="http://blog.integryst.com/webcenter-interaction/files/2010/07/DisplayFilter.zip">DisplayFilter.zip</a> for the binaries (source and config files included).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.integryst.com/webcenter-interaction/2010/05/03/bug-blog-4-fix-broken-file-downloads-in-10gr3-part-duex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bug Blog 3: Fix Broken File Downloads in 10gR3</title>
		<link>http://blog.integryst.com/webcenter-interaction/2010/04/29/bug-blog-3-fix-broken-file-downloads-in-10gr3/</link>
		<comments>http://blog.integryst.com/webcenter-interaction/2010/04/29/bug-blog-3-fix-broken-file-downloads-in-10gr3/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 09:27:17 +0000</pubDate>
		<dc:creator>Matt Chiste</dc:creator>
				<category><![CDATA[Bug]]></category>
		<category><![CDATA[Coding Tricks]]></category>
		<category><![CDATA[Knowledge Directory]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.integryst.com/webcenter-interaction/?p=332</guid>
		<description><![CDATA[Wow, was WebCenter Interaction 10gR3 a step backwards in opening documents, or what?  I&#8217;ve seen wide-spread problems opening docs in the Knowledge Directory, Search Results, and Snapshot Queries, and even written two posts on the topic already. There are two main problems: poorly implemented document open handlers (which I&#8217;ll discuss in my next post), and [...]]]></description>
			<content:encoded><![CDATA[<p>Wow, was WebCenter Interaction 10gR3 a step backwards in opening documents, or what?  I&#8217;ve seen wide-spread problems opening docs in the Knowledge Directory, Search Results, and Snapshot Queries, and even written <a href="http://blog.integryst.com/webcenter-interaction/2010/01/21/fix-kd-handling-of-html-docs/" target="_self">two</a> <a href="http://blog.integryst.com/webcenter-interaction/2010/02/14/opening-excel-documents-from-the-wci-knowledge-directory/" target="_self">posts</a> on the topic already.</p>
<p>There are two main problems: poorly implemented document open handlers (which I&#8217;ll discuss in my next post), and that pesky Content-Disposition header that tries to force the browser to throw up an &#8220;Open/Save&#8221; dialog instead of just opening inline (which is definitely useful for HTML and Office files in particular, where users just want to view the documents in their browser without having to save &#8216;em first).  A third but ancillary issue is that occasionally the portal gets the MIME type of the document wrong in the Content-Type header, which is typically using application/octet-stream and doesn&#8217;t give the browser any clue about what type of file it is.</p>
<p>In the <a href="http://blog.integryst.com/webcenter-interaction/2010/01/21/fix-kd-handling-of-html-docs/" target="_self">past</a> <a href="http://blog.integryst.com/webcenter-interaction/2010/02/14/opening-excel-documents-from-the-wci-knowledge-directory/" target="_self">posts</a> I&#8217;ve described using BigIP iRules to remove the Content-Disposition header, but I ran into another client issue recently where just killing this header isn&#8217;t enough.  Take the following response headers for a document transfer that is NOT using the iRule to kill the Content-Disposition header:</p>
<p><a href="http://blog.integryst.com/webcenter-interaction/files/2010/04/bad-content-type.png"><img class="alignnone size-full wp-image-333" title="bad-content-type" src="http://blog.integryst.com/webcenter-interaction/files/2010/04/bad-content-type.png" alt="" width="269" height="198" /></a></p>
<p>This PowerPoint file, when clicked on in the portal, will throw the open/save dialog, but what if we wanted it to give the browser the option to open in-line?  We&#8217;d get rid of that Content-Disposition header.  Here&#8217;s the problem:  if we do that, the portal is returning a Content-Type of application/octet-stream.  Which means, without the file extension in Content-Disposition, the browser has no idea what type of document this is, so it throws up a &#8220;FIND PROGRAM/Save&#8221; dialog box instead of an &#8220;OPEN/Save&#8221; dialog box.</p>
<p>The solution to this problem would be to drop the Content-Disposition header, but use the file extension to fix the Content-Type while we&#8217;re at it (to application/vnd.ms-powerpoint).  But now our iRules are getting complicated, and not everyone has BigIP anyway.  Fortunately, <a href="http://blog.integryst.com/webcenter-interaction/2010/04/17/webcenter-patch-and-hotfix-round-up/" target="_self">my love/hate relationship</a> with support.oracle.com shifted much more to the former when i found this: <a href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;doctype=HOWTO&amp;id=971003.1" target="_blank">How to Eliminate the &#8216;Save/Open with&#8217; Prompt when Opening HTML Files [ID 971003.1]</a>.  Then, of course, it shifted back to the latter when I realized that I found this article by complete dumb luck navigating the terrible interface, and the article is nowhere to be found searching through Google. But that&#8217;s another story.</p>
<p>At any rate, a solution was clear: you can write a .NET or Java FILTER to manipulate headers before they&#8217;re returned to the browser!  As such, I took the code from that article and expanded on it with a .NET filter of my own, which will:</p>
<ol>
<li>Remove the Content-Disposition header selectively on different file types</li>
<li>Change the Content-Disposition header to use &#8220;inline&#8221; instead of &#8220;attachment&#8221; instead of just deleting the header (this seems to work with some browsers; a brief discussion on the differences is <a href="http://dotanything.wordpress.com/2008/05/30/content-disposition-attachment-vs-inline/" target="_blank">here</a>)</li>
<li>Fix the Content-Type header if the file name extension doesn&#8217;t map the MIME type the portal thinks it is</li>
<li>Do all this through a filter and a dynamically loadable varpack that allows different configurations based on the type of file being served.</li>
</ol>
<p>So while it&#8217;s a bit optimized in the sense that it only looks at responses being gatewayed through the portal, it&#8217;s still kind of a hack because personally, I think this should be an option in the portal in the first place rather than adding the additional overhead of a filter.</p>
<p>But, nonetheless, it seems to work well, and you can download the code <a href="http://portal.integryst.com/site/integryst.i/gateway/PTARGS_0_200_549_0_0_18/disposition.cs" target="_self">here</a> and the varPack file <a href="http://portal.integryst.com/site/integryst.i/gateway/PTARGS_0_200_548_0_0_18/integrystopener.xml" target="_self">here</a>.</p>
<p>If you&#8217;d like assistance with actually building and deploying this, or porting to Java &#8211; <a href="http://www.integryst.com/site/integryst.i/page/contact_us/206" target="_self">drop me a line</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.integryst.com/webcenter-interaction/2010/04/29/bug-blog-3-fix-broken-file-downloads-in-10gr3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The perils and pitfalls of the WCI gateway transformer</title>
		<link>http://blog.integryst.com/webcenter-interaction/2010/04/03/the-perils-and-pitfalls-of-the-wci-gateway-transformer/</link>
		<comments>http://blog.integryst.com/webcenter-interaction/2010/04/03/the-perils-and-pitfalls-of-the-wci-gateway-transformer/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 07:43:08 +0000</pubDate>
		<dc:creator>Matt Chiste</dc:creator>
				<category><![CDATA[Coding Tricks]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[gateway]]></category>
		<category><![CDATA[transformer]]></category>

		<guid isPermaLink="false">http://blog.integryst.com/webcenter-interaction/?p=251</guid>
		<description><![CDATA[All right, so you know my ol&#8217; phrase &#8220;browser to portal, portal to back-end server&#8220;.  That is, the browser connects to the portal, the portal connects to the back-end-server (i.e., your custom code), back-end server sends HTML to the portal, the portal parses and transforms that HTML and returns it to the browser.  This post [...]]]></description>
			<content:encoded><![CDATA[<p>All right, so you know my ol&#8217; phrase &#8220;<a href="http://www.function1.com/2007/09/know-your-traffic-flow-part-ii/" target="_blank">browser to portal, portal to back-end server</a>&#8220;.  That is, the browser connects to the portal, the portal connects to the back-end-server (i.e., your custom code), back-end server sends HTML to the portal, <strong>the portal parses and transforms that HTML </strong>and returns it to the browser. </p>
<p>This post is about that step where the portal transforms the HTML you return from the your custom code.  I could be incredibly long-winded here about all sorts of tricks and nuances of <a href="http://download-llnw.oracle.com/docs/cd/E13174_01/alui/devdoc/docs60/Portlets/Adaptive_Portlets/Using_Adaptive_Tags/plumtreedevdoc_integration_portlets_adaptive_namespacetoken.htm#URLtransformation" target="_blank">some adaptive tags</a> that seem to only half-work, but figured I&#8217;d just share some quick tips to give you some ideas on how you can trick the gateway engine to do your bidding.<br />
<span id="more-251"></span><br />
<hr /><strong>Problem: </strong>You do NOT want a URL transformed, and just want to link to something like /portal/server.pt?open=512&amp;objID=382.  If you just use &lt;a href=&#8221;/portal/server.pt?open=512&amp;objID=382&#8243;&gt;, the portal will think you&#8217;re trying to use a link relative to your application and helpfully transform it for you.  </p>
<p><strong>Solution: </strong> The portal&#8217;s parser isn&#8217;t all that smart; it just parses the DOM and looks for items like &lt;img src&gt; or &lt;a href&gt; parameters, so if you obfuscate the link a bit, the portal won&#8217;t detect it as a &#8220;real&#8221; link: </p>
<p>               document.write(&#8216;&lt;a hre&#8217; + &#8216;f=&#8221;/portal/server.pt?open=512&amp;objID=382&#8243;&gt;link text&lt;/a + &#8216;&gt;&#8217;); </p>
<hr /><strong>Problem</strong>: You have a URL defined in a properties file that you DO want to make sure is transformed, even if it&#8217;s in some place in your JS code that the transformer usually can&#8217;t detect (like a JS variable). </p>
<p><strong>Solution #1</strong>: Add the variable to an object, set the object.location, and use that string so that when rendered, the transformer will wrap its transformation javascript around your code: </p>
<p>                var actionServlet = new Object();</p>
<p>                actionServlet.location = &#8216;&lt;%=SERVLET_URL%&gt;&#8217;;</p>
<p>                var actionServletURL = actionServlet.location; </p>
<p><strong>Solution #2</strong>: Directly call the Javascript method available on every page to manually transform the link: </p>
<p>               var actionServletURL = pt_&lt;%=portletID%&gt;.transformURL(&#8216;&lt;%=SERVLET_URL%&gt;&#8217;); </p>
<hr /><strong>Problem</strong>: You&#8217;ve an entire JavaScript file that has to be gatewayed, but you&#8217;d just like the portal to &#8220;pass it through&#8221; without parsing it at all. </p>
<p><strong>Solution</strong>: The portal looks at the MIME type of a document/file before it decides to parse it, and is pretty strict about only parsing MIME types with &#8220;text/*&#8221; in them (like &#8220;text/javascript&#8221;).  But browsers aren&#8217;t so strict!  So if you set the MIME type of your javascript file to &#8220;application/javascript&#8221;, the portal won&#8217;t transform it, but the browser will still run it like any other javascript file: </p>
<p>               response.setHeader(&#8220;Content-Type&#8221;, &#8220;application/javascript; charset=utf-8&#8243; );</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.integryst.com/webcenter-interaction/2010/04/03/the-perils-and-pitfalls-of-the-wci-gateway-transformer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Free Oracle WebCenter Interaction Code!</title>
		<link>http://blog.integryst.com/webcenter-interaction/2010/01/25/free-oracle-webcenter-interaction-code/</link>
		<comments>http://blog.integryst.com/webcenter-interaction/2010/01/25/free-oracle-webcenter-interaction-code/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 04:54:01 +0000</pubDate>
		<dc:creator>Matt Chiste</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[BEA]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Plumtree]]></category>

		<guid isPermaLink="false">http://blog.integryst.com/webcenter-interaction/?p=68</guid>
		<description><![CDATA[Sorry if the title of this post sounded sensational; this code has been around forever.  In fact, it&#8217;s kind of ancient, and as far as I can tell hasn&#8217;t had new submissions in years.  But for those of you looking for the old BEA &#8220;CodeShare&#8221; repository, this is the link you&#8217;re looking for.  All the [...]]]></description>
			<content:encoded><![CDATA[<p>Sorry if the title of this post sounded sensational; this code has been around forever.  In fact, it&#8217;s kind of ancient, and as far as I can tell hasn&#8217;t had new submissions in years.  But for those of you looking for the old BEA &#8220;CodeShare&#8221; repository, this is the link you&#8217;re looking for.  All the classics are here: Lotus Notes / SAP / PeopleSoft / Exchange Portlet Suites, Java Portlet Tools, the Publisher Blog Templates, Sample Code (including some under-publicized Social Network portlets).</p>
<p>You won&#8217;t need any of this stuff today (or tomorrow), but someday when you&#8217;re pulling your hair out and thinking to yourself &#8220;if only BEA&#8217;s CodeShare was still around!&#8221;, this is the link you&#8217;re looking for: <a href="https://aqualogic-interaction.samplecode.oracle.com/">https://aqualogic-interaction.samplecode.oracle.com/</a> (free registration/login required).</p>
<p><img class="alignnone size-full wp-image-69" title="codesamples" src="http://blog.integryst.com/webcenter-interaction/files/2010/01/codesamples.PNG" alt="codesamples" width="595" height="363" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.integryst.com/webcenter-interaction/2010/01/25/free-oracle-webcenter-interaction-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

