1
votes

I have a SharePoint webpart page, with a parameter in the page Querystring (in the URL), and I also have a Page Viewer webpart (which effectively IFRAME's the specified webpage), which shows a Java applet.

Is there any way I can get the parameter in the SharePoint Querystring to be recieved by the Java Applet ?

The reason for doing a Java applet in a webpart is to allow a file to be dragged and dropped onto the Java applet, and the parameter shows where the file would be saved in the SharePoint Document Centre.

I'd appreciate any and all suggestions.

Cheers

Nick

Notes:

  1. The Querystring in the sharepoint page cannot be read by the Java Applet directly, due to the 'walls' setup around the Page Viewer webpart.
  2. I've tried creating a cookie when the SharePoint page is loaded, then reading the cookie when the Java applet is loaded (upon recieving the file, so it's not a timing thing), but it can't access the cookie (different domains ?)
4
@Old Nick: Can you expand on what you mean by "walls"? What does the HTML for the Java applet look like when embedded within the CEWP, and what should it look like? Perhaps you could update your question with this.Alex Angas
Walls : as in, Sharepoint doesn't allow any visibility of the sharepoint application from a webpage rendered inside a content editor webpart. This has the advantage that SharePoint doesn't disrupt the webpage, but the disadvantage is that there is no way of seeing the user context in sharepoint.Nick Haslam
My bad typing, its a page viewer webpart, not a content editor webpart. Brain was addled..... :)Nick Haslam

4 Answers

2
votes

Sounds like your two webpages run from different domains. In that case, you need to use one of the Cross-Domain Communication tricks to break the walls.

Read this article,

http://msdn.microsoft.com/en-us/library/bb735305.aspx

This is my favorite approach. To summarize it,

  1. You need to create a simple webpart page on the applet domain which contains some Javascript to pass the URL fragment (after #) to the applet window. Let's call it xd_helper (cross-domain helper).
  2. When you have the URL in the other webpart, you call the xd_helper#querystring.
  3. The xd_helper can send the querystring to the applet because they are on the same domain.

The xd_helper Javascript can be very simple. Look at the one used by Google Friend Connect,

var u=location.href,h=u.substr(u.indexOf("#")+1).split("&"),t,r;try{t=h[0]===".."?parent.parent:parent.frames[h[0]];r=t.gadgets.rpc.receive}catch(e){}r&&r(h);

Facebook uses a more verbose version,

http://static.ak.facebook.com/js/api_lib/v0.4/XdCommReceiver.js?2

1
votes

SharePoint and the Page Viewer Web Part probably aren't the issue here directly. As you state, the 'walls' that you describe are an HTML IFrame tag. You could focus your search on if the query string is accessible when the applet is within an IFrame.

Alternatively, why don't you use the Content Editor Web Part? That allows you to include any arbitrary HTML directly onto the page. Instead of passing parameters by query string, pass them through on the object tag:

<object 
  classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
  width="200" height="200">
  <param name="code" value="Applet1.class">
  <param name="paramX" value="valueX">
</object>

You should be able to retrieve with:

String name = getParameter("paramX");
0
votes

Have you tried reading the querystring using JS then document.writing the embed code for the applet?

0
votes

Found a link to this blog which covers how to pass parameters to a content editor webpart, which then resolved the issue.