我可以将复杂的参数传递给 Java Applet 吗?

发布于 2024-08-19 16:11:57 字数 1109 浏览 1 评论 0原文

我对 Java 很陌生,我必须创建一个用于电子签名文档的小程序。该小程序将从 ASP.Net 网页应用程序调用。

现在,我将小程序作为 嵌入页面中,并将参数发送到小程序,如下所示this:

<PARAM id="EdocPath" NAME="EdocPath" value="\\some\where\file.txt" />

在小程序中,我可以使用小程序的内置方法 getParameter("EdocPath") 获取值;

我需要的是能够向小程序传递多个文件及其“显示名称”的列表。例如,像 XML 字符串一样写下来很简单:

<DocumentList>
  <UnsignedDocument Path="\\some\wehere\file1.txt" Description="Whatever comes here" />
  <UnsignedDocument Path="\\some\wehere\file2.txt" Description="Something else" />
...

但是,据我在 HTML4.01 规范PARAM HTML 元素可能没有内容,也没有结束标记。

我正在考虑的选择是:

  • 对 xml 结构进行 html 编码,并将其发送到单个 PARAM 对象中的小程序
  • 创建 PARAM 对象列表并构造它们的名称,如“File1”、“Description1”、“File2”、“Description2” ", "File3"...然后在 Java 小程序中创建一个 while 循环来读取文件名。

然而,这些解决方案似乎都不是优雅的。问题是,这种情况下的最佳做法是什么?

I'm really new to Java and I have to create an applet for signing documents electronically. The applet will be called from an ASP.Net web page application.

Right now, I embed the applet in page as a <object id="EDOCApplet" classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"> and send parameters to the applet like this:

<PARAM id="EdocPath" NAME="EdocPath" value="\\some\where\file.txt" />

In the applet, I can get the value using applet's built-in method getParameter("EdocPath");

What I need is the ability to pass the applet a list of several files and their "display names". For instance, it would be simple to write it down like an XML string:

<DocumentList>
  <UnsignedDocument Path="\\some\wehere\file1.txt" Description="Whatever comes here" />
  <UnsignedDocument Path="\\some\wehere\file2.txt" Description="Something else" />
...

However, as far as I see in HTML4.01 specification, the PARAM HTML element may not have content and it has no end-tag.

The choices I'm considering, are:

  • html-encode the xml structure and send it to applet in a single PARAM object
  • creating a list of PARAM objects and constructing their names like "File1", "Description1", "File2", "Description2", "File3"... then in Java applet create a while loop to read filenames while there is any.

However, none of the solutions seems to be elegant. The question is, what's the best practice in this case?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鹿童谣 2024-08-26 16:11:57

以逗号分隔传递它们:

<param id="files" name="files" 
     value="\\some\where\file.txt,\\some\where\file.txt" />

然后使用 String.split()

String[] fileNames = param.split(",");

如果结构更复杂,您可以使用 JSON 来表示它们。

Pass them comma-separated:

<param id="files" name="files" 
     value="\\some\where\file.txt,\\some\where\file.txt" />

and then use String.split():

String[] fileNames = param.split(",");

In case of more complex structures you can use JSON to represent them.

暖树树初阳… 2024-08-26 16:11:57

您还可以为您的小程序提供一个公共方法:

initFile(String path, String description)

并从 javascript 代码调用此方法(您可以在其中循环)

var applet = getElementByTageName(applet);
applet.initFile("yourPath","yourDescription");

You can also provide your applet with a public method:

initFile(String path, String description)

and call this method from javascript code (in which you can loop)

var applet = getElementByTageName(applet);
applet.initFile("yourPath","yourDescription");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文