Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
0 Kudos
905
So, how did we go about creating the type of functionality that you see here on SDN for the forums, weblogs and even the wiki or any other external web application. (although there are things we are still working on). First things first Before reading any further, the only way that this will work is to have the external web application in the same domain as the current portal. By default a domain for a web page is normally set to the full name of the server, in our case this would be www.sdn.sap.com. Now, as most, if not all, of you are aware, the portal will relax the domain of the portal server by default, or configurable so that we can relax it more than a single level. Therefore the domain of the SDN website is set to sdn.sap.com (notice the removal of the www). With the forums web application, we have had to put in the code ourselves that relaxes the domain: - // Domain relaxing if ( document.domain.indexOf(".") > 0 ) document.domain = document.domain.substr(document.domain.indexOf(".")+1); Otherwise the domain would be forums.sdn.sap.com instead of sdn.sap.com. Now, this would simply not do, thanks to the security restrictions of browser, which stops cross site scripting. The other thing to note is that access to the external system also need to be of the same protocol as the portal server, i.e. HTTP-->HTTP or HTTPS-->HTTPS. HTTP-->HTTPS will simply not work. Thas all been done, on SDN, using the EFP (Externally Facing Portal) funcionality, so has not been tested on the full portal desktop, although the same principals could be applied. Now to the nitty gritty There are several steps to follow, so please be patient. 1) New Content Area Component
  • We needed to create our own content area component. As many are aware ALL iviews are generally displayed using a content area iview is added to the innerpage page. The innerpage is added to the portal desktop.
    • LightWorkAreaiView
    • WorkAreaData
    • WorkAreaHelper
2) Changes to the LightWorkAreaiView class
  • The LightWorkAreaiView class is responsible for outputting the iframe tag, so all of our changes will be done there, other than the javascript (which will be detailed further down).
  • The main thing to do is to add an onload event to the iframe that is generated. To do this simply add the following code to the iframe tag, onload="workArea.resizeIframe()", so you iframe should look something like . This will mean that the workArea.resizeIframe() method will be called everytime the contents within the iframe is reloaded. This includes navigating around the site, as you do with the forums.
3) Changes to the javascript code
  • Copy the light_workArea.js file from the com.sap.portal.navigation.contentarea. This is found in the public area of the portal, root/portalapps/com.sap.portal.navigation.contentarea/scripts folder, into the dist/scripts folder of your NWDS project.
  • Find the workArea.resizeIframe javascript function in the javascript file and replace the code with this
  • workArea.resizeIframe = function(){ //Get the IFRAME object obj = document.getElementById("isolatedWorkArea"); DEFAULT_HEIGHT = '6000'; if (obj != null){ try{ reqsize = window.frames[obj.name].document.body.scrollHeight + 100 ; obj.style.height = reqsize + 'px'; obj.style.width = '100%'; var width; //This code is added because IE adds 16px for the scrollbar if(navigator.appName == "Microsoft Internet Explorer") width = parseInt(window.frames[obj.name].document.body.scrollWidth) + 16; else window.frames[obj.name].document.body.scrollWidth; obj.style.width = width + 'px'; }catch(e){ try{ obj.style.height = DEFAULT_HEIGHT + 'px'; }catch(e){} } } }
  • deploy the par file generated by this NWDS
4) Configuration required
  • Create an iview based on your par file
  • Create a copy of the standard desktop and of the innerpage and store these in some place of your choosing within the PCD.
  • Assign the copied desktop using the desktop rules.
  • Change the inner page so that it now has your custom content area iview instead of the standard one
Hey Presto The pages should now be resized not only in height, but in width also and that should be the end of those pesky scrollbar critters. Thanks Darrell
5 Comments