javascript 从applet 取值问题请教
执行applet,包括以下代码:
TO中:
private EEPTempData rfIDData = null;
public EEPTempData getRfIDData() {
return rfIDData;
}
public void setRfIDData(EEPTempData rfIDData) {
this.rfIDData = rfIDData;
}
private EEPTempEndorsementData rfIDEndorsementData[] = null;
public EEPTempEndorsementData[] getRfIDEndorsementData() {
return rfIDEndorsementData;
}
public void setRfIDEndorsementData(EEPTempEndorsementData rfIDEndorsementData[]) {
this.rfIDEndorsementData = rfIDEndorsementData;
}
run 方法中:
EEPTempData tempData = new EEPTempData();
tempData.setNatCd("CHN");
this.applet.setRfIDData(tempData);
EEPTempEndorsementData tempEndosements[] = new EEPTempEndorsementData[2];
EEPTempEndorsementData endorsementData1 = new EEPTempEndorsementData();
EEPTempEndorsementData endorsementData2 = new EEPTempEndorsementData();
endorsementData1.setNatCd("CHN");
endorsementData2.setNatCd("CHN");
tempEndosements[0] = endorsementData1;
tempEndosements[1] = endorsementData2;
this.applet.setRfIDEndorsementData(tempEndosements);
在jsp页面通过javascrit 取值:
可以取到单个实例的值:
alert(document.applets['EEPOCRApplet'].getRfIDData().getNatCd()); 显示 CHN
但是取不到实例数组的值:
document.applets['EEPOCRApplet'].getRfIDEndorsementData()[0] 出错。
alert(typeof(document.applets['EEPOCRApplet'].getRfIDEndorsementData())); 显示 unknown
请大虾们帮帮忙,谢谢
------解决方案--------------------可以在java中将array转成json格式string,然后再js中解析
------解决方案--------------------js与Applet的通讯似乎只能传递串,因此,数组等属于对象的数据就不能传递了!
可以借助其他方式来实现,如楼上提到的json等