0
问题陈述重装:重装小程序无需重新加载浏览器方面采取小应用程序使用Java脚本
计算策略:
我大概以为JavaScript就无法调用Applet的生命周期方法等等而不是从JavaScript调用applet生命周期的开始方法我创建我自己的mystart方法,我正在做我的小应用程序的东西,并尝试在JavaScript中调用mystart方法...它并没有帮助,并在这种情况下抛出安全访问voilation。
我有一个名为setdieseasename的方法在我的applet中,我可以从我的javascript调用。
我的javascript:
function showSelected(value){
alert("i am in the javascript code atleast ");
var applet =document.getElementById('decisiontreeapplet');
alert("i am adding before the myinit call");
applet.setDieasename(value);
alert("i am adding after the myinit call");
applet.myStart();
alert("i am here after calling mystart method");
}
applet代码: 包com.vaannila.utility;
//import java.applet.AppletContext;
import java.applet.AppletContext;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import prefuse.util.ui.JPrefuseApplet;
public class dynamicTreeApplet extends JPrefuseApplet {
private static final long serialVersionUID = 1L;
public static int i = 1;
public static String dieasenameencode="Malaria";
public void init() {
}
@Override
public void start() {
super.start();
myStart();
}
public void myStart() {
System.out.println(" i am in the mystart method 111111111111");
URL url = null;
String dencode=null;
String dieasename=null;
if (dieasenameencode!=null){
dencode = dieasenameencode.trim();
System.out.println("the codebase to check if dencode is null method 2222222222222222222 ");
}
try {
if(dencode!=null){
System.out.println("the codebase to check if dencode is null method 3333333333333333 ");
dieasename = URLEncoder.encode(dencode, "UTF-8");
}
System.out.println(" i am just before the url connection code 444444444444444444");
url = new URL("http://localhost:8080/docRuleToolProtocol/refreshAction.do?disease_name="+dieasename);
System.out.println("i am after url connection 55555555555555555555");
URLConnection con = url.openConnection();
System.out.println(" i am here after creating a open connection 666666666666666");
con.setDoOutput(true);
con.setDoInput(true);
con.setUseCaches(false);
InputStream ois = con.getInputStream();
this.setContentPane(dynamicView.demo(ois, "name"));
ois.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (FileNotFoundException f) {
f.printStackTrace();
} catch (IOException io) {
io.printStackTrace();
}
++i;
}
public void setDieasename(String message){
System.out.println("atleast i am here and call is made ");
dieasenameencode=message;
myStart();
}
}
*“问题陈述:重新加载小程序不重新加载浏览器上下文“*不,看来问题是不得不通过重新载入来刷新小程序。向刷新它的小程序添加一个按钮。 –