我需要通过applet打印一些信息。 我的applet来自签名的qds-client.jar:
public class PrintText extends Applet implements Printable {
private ClientAccount clientAccount;
public ClientAccount getClientAccount() {
return clientAccount;
}
public void setClientAccount (ClientAccount clientAccount) {
this.clientAccount = clientAccount;
}
public void setClientAccountFromJSON(String json) {
this.clientAccount = toClientAccountFromJSON(json);
System.out.println("------------------------------SetClient");
}
public int print(Graphics g, PageFormat format, int page) throws
...
}
public void printText() throws PrinterException {
...
}
private String getTextToPrint(ClientAccount clientAccount) throws PrinterException {
...
}
private ClientAccount toClientAccountFromJSON(String json) {
return JsonUtils.fromJson(ClientAccount.class, json);
}
public void startPrint () {
System.out.println("------------------------------------------Start");
}
}
Accordinng JNLP:
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.5+" codebase="http://localhost:10099/partials/" href="print.jnlp">
<information>
....
</information>
<resources>
<jar href="/partials/qds-client.jar"/>
<jar href="/partials/core-3.2.1.jar"/>
<jar href="/partials/gson-2.3.1.jar"/>
</resources>
<applet-desc name="printText" main-class="com.qdsrest.utils.printer.PrintText" width="500" height="200"></applet-desc>
<update check="background"/>
<security>
<all-permissions/>
</security>
和HTML标记:
<applet name="printApplet" jnlp_href="/partials/print.jnlp" width="10" height="10">
<param name="permissions" value="all-permissions"/>
</applet>
当我从js文件中调用applet的方法时:
document.printApplet.setClientAccountFromJSON({/not empty/});
我得到了
Error: Error calling method on NPObject!
在Mozilla和
basic: JNLP2ClassLoader.findClass: com.google.gson.internal.bind.CollectionTypeAdapterFactory: try again ..
basic: JNLP2ClassLoader.findClass: com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter: try again ..
basic: JNLP2ClassLoader.findClass: com.google.gson.internal.bind.MapTypeAdapterFactory: try again ..
basic: JNLP2ClassLoader.findClass: com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter: try again ..
basic: JNLP2ClassLoader.findClass: com.google.gson.internal.bind.JsonAdapterAnnotationTypeAdapterFactory: try again ..
Java控制台和方法中的不起作用。为什么我会“再试一次......”?这是什么意思? 方法toClientAccountFromJSON使用GSON lib gson-2.3.1.jar将JSON对象完全反序列化为Java对象。我做了什么错事?请告诉我一个正确的思考方式。
答案 0 :(得分:0)
我不记得当前的细节,但很久以前,在第一次浏览器大战时,曾经有一个属性using HP.LFT.SDK.WPF;
,你的applet需要与javascript交谈。
哦,参数需要是字符串:
mayscript