当前位置: 代码迷 >> Java Web开发 >> javascript 从applet 取值问题请教
  详细解决方案

javascript 从applet 取值问题请教

热度:239   发布时间:2012-02-09 11:56:26.0
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   
请大虾们帮帮忙,谢谢
搜索更多相关主题的帖子: void  javascript  private  public  return  

----------------解决方案--------------------------------------------------------
既然不能取数组,就一个一个取吧,实现方法是:
public EEPTempEndorsementData getRfIDEndorsementData(int index) {
  if (index < rfIDEndorsementData.length) {
  return rfIDEndorsementData[index];
  }
  return null;
  }

javascript:
var endDataFlag = true;
var endNum = 0;
while (endDataFlag) {
  var endData = document.applets['EEPOCRApplet'].getRfIDEndorsementData(endNum);
  if (endData == undefined) {
  break;
  }
  alert(endData.getTdNo());
}
----------------解决方案--------------------------------------------------------
希望有从applet 取数组的方法拿出来晒晒,谢谢
----------------解决方案--------------------------------------------------------
  相关解决方案