From: Sarel B. <sar...@do...> - 2010-02-05 05:17:06
|
Hi, David, It doesn't look like this is currently possible, but it shouldn't be hard to implement. You'll have to download the source code to make these modifications. If you pass a parameter to the applet with a param tag you can retrieve the value by calling getParameter("key") on the ij.ImageJApplet class. I would make a static instance variable in the ImageJApplet class, then in the init() method set the instance variable to 'this', also add a public method getInstance() to retrieve the ImageJApplet instance object. This should allow you to retrieve the parameters. Hope this helps. Regards, Sarel -----Original Message----- From: Pinelle, David [mailto:dav...@us...] Sent: Wednesday, February 03, 2010 3:07 PM To: ima...@li... Subject: [Imageja-devel] Passing macro arguments to ImageJA I am using ImageJA as a viewer for a radiological teaching file system. So far, so good, but I have a question about passing arguments (using the HTML PARAM tag) to the applet. I am able to pass the URLs for images to the applet without any problem, and people are able to interactively select images in my system, and then the images are displayed in the ImageJA viewer. My goal now is to be able to pass several variables to the applet and then to be able to write an ImageJ macro or plug-in that can manipulate the variables. I noticed that the ImageJApplet class has been modified in ImageJA, and it accepts macro expressions or macros posted in URLs. It seems like this should solve my problem, but I have not been able to get this feature to work properly. I have passed in my variables as macro expressions, and I have also passed in a short macro as an expression. I have tried several variations on this: I have passed in the variables as separate eval parameters, and I have tried interacting with the variables in macros launched through StartupMacros.txt, etc., but without much luck. Nothing seems to happen when I run my code, and when I try to access the variables in other macros, they are not recognized. This code runs in a Java servlet that is deployed in Tomcat. Everything works and has been tested extensively...except the arguments that are being passed in using the eval1 parameter. The part that is included in the eval1 PARAM is a simple test macro that is supposed to print the variables to the screen so that I can make sure they reach the applet okay. When I run this code, the ImageJA applet does not acknowledge the eval1 PARAM. My main question is whether this functionality is fully implemented at this point (passing in macros) and whether I am doing this correctly. I also would like to know how the variables passed in through the eval parameter are scoped. If, for example, I pass in a variable like this: applet.append("<PARAM NAME=eval1 VALUE=\"var host=\""+req.getHeader("host")+"\";\" >"); How/where can I access it once it reaches the applet (using macros or plugins)? Thanks and regards, David String reqURL = req.getRequestURL().toString(); int k = reqURL.indexOf("://") + 3; //get past the protocol k = reqURL.indexOf("/",k) + 1; //get to the beginning of the servlet name k = reqURL.indexOf("/",k) + 1; //get to the end of the servlet name, plus the slash StringBuffer applet = new StringBuffer(); applet.append("<HTML><BODY>"); applet.append("<APPLET "); String codebase = reqURL.substring(0,k) + "dicomviewer/imagej"; applet.append("CODEBASE=\""+codebase+"\" "); applet.append("ARCHIVE=\"ij.jar\" "); applet.append("CODE=\"ij.ImageJApplet.class\" "); applet.append("NAME=\"Viewer.java\" "); applet.append("WIDTH=\"100% \" "); applet.append("HEIGHT=\"100%\" "); applet.append("HSPACE=\"0\" "); applet.append("VSPACE=\"0\" "); applet.append("ALIGN=\"top\" "); applet.append(">"); applet.append("<PARAM name=\"java_arguments\" value=\"-Xmx256m\">"); applet.append("<PARAM NAME=url1 VALUE=\""+reqURL+"\">"); //THIS IS WHERE I AM HAVING PROBLEMS applet.append("<PARAM NAME=eval1 VALUE=\""+ "var host=\""+req.getHeader("host")+"\";"+System.getProperty("line.separator" )+ "var authorization=\""+req.getHeader("authorization")+"\";"+System.getPropert y("line.separator")+ "var useragent=\""+req.getHeader("user-agent")+"\";"+System.getProperty("line .separator")+ "var accept=\""+req.getHeader("accept")+"\";"+System.getProperty("line.separa tor")+ "var keepalive=\""+req.getHeader("keep-alive")+"\";"+System.getProperty("line .separator")+ "var referer=\""+req.getHeader("referer")+"\";"+System.getProperty("line.sepa rator")+ "print (\"The arguments are:\");"+System.getProperty("line.separator")+ "print (\"host \" + host);"+System.getProperty("line.separator")+ "print (\"authorization \" + authorization);"+System.getProperty("line.separator")+ "print (\"useragent \" + useragent);"+System.getProperty("line.separator")+ "print (\"accept \" + accept);"+System.getProperty("line.separator")+ "print (\"keepalive \" + keepalive);"+System.getProperty("line.separator")+ "print (\"referer \" + referer);"+System.getProperty("line.separator")+ "print (\"--\"); \" >"); applet.append("</APPLET>"); applet.append("</BODY></HTML>"); ------------------------------------------------------------------------ ------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ Imageja-devel mailing list Ima...@li... https://lists.sourceforge.net/lists/listinfo/imageja-devel |