简体   繁体   English

将Querystring参数从SharePoint传递到Java Applet Webpart

[英]Pass Querystring parameter from SharePoint to Java Applet webpart

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. 我有一个SharePoint Webpart页面,在页面的Querystring(在URL中)中有一个参数,还有一个Page Viewer Webpart(实际上是IFRAME的指定网页),其中显示了一个Java applet。

Is there any way I can get the parameter in the SharePoint Querystring to be recieved by the Java Applet ? 有什么方法可以获取Java Applet接收的SharePoint Querystring中的参数?

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. 在Webpart中执行Java小程序的原因是允许将文件拖放到Java小程序中,并且该参数显示文件在SharePoint文档中心中的保存位置。

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. 共享点页面中的查询字符串不能被Java Applet直接读取,这是因为页面查看器Web部件周围的“墙”设置。
  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 ?) 我尝试在加载SharePoint页面时创建cookie,然后在加载Java applet时读取cookie(接收到文件后,这不是计时问题),但是它无法访问cookie(不同的域? )

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 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. 您需要在applet域上创建一个简单的Webpart页面,其中包含一些Javascript,以将URL片段(在#之后)传递到applet窗口。 Let's call it xd_helper (cross-domain helper). 我们称它为xd_helper(跨域帮助器)。
  2. When you have the URL in the other webpart, you call the xd_helper#querystring. 当您在另一个Webpart中拥有URL时,您将调用xd_helper#querystring。
  3. The xd_helper can send the querystring to the applet because they are on the same domain. xd_helper可以将查询字符串发送到applet,因为它们位于同一域中。

The xd_helper Javascript can be very simple. xd_helper Javascript可能非常简单。 Look at the one used by Google Friend Connect, 看一看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, Facebook使用更详细的版本,

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

SharePoint and the Page Viewer Web Part probably aren't the issue here directly. SharePoint和Page Viewer Web部件可能不是这里的直接问题。 As you state, the 'walls' that you describe are an HTML IFrame tag. 如您陈述的那样,您描述的“墙”是HTML IFrame标签。 You could focus your search on if the query string is accessible when the applet is within an IFrame. 当小程序位于IFrame中时,您可以集中精力查询是否可访问查询字符串。

Alternatively, why don't you use the Content Editor Web Part? 或者,为什么不使用内容编辑器Web部件? That allows you to include any arbitrary HTML directly onto the page. 这样,您就可以将任意HTML直接包含在页面中。 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");

您是否尝试过使用JS然后使用document.write小程序的嵌入代码来读取查询字符串?

找到了指向此博客的链接,该链接涵盖了如何将参数传递给内容编辑器Webpart,然后该WebPart解决了该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM