We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Saving settings from a Processing object / applet
Page Index Toggle Pages: 1
Saving settings from a Processing object / applet (Read 307 times)
Saving settings from a Processing object / applet
Nov 27th, 2008, 4:58pm
 
Hello

I am completely new to Processing and I want to use it in a web application I'm writing in NetBeans 6.5 where users
are able to graph data on bar charts, time series plots and so on.

Using Processing, I can export the application as an applet and and use the .jar file in my NetBeans application to
generate the graphs I want in a web page. This works perfectly well where the applet it is passed the name of the
text file on the server which contains the data (which is written from a MySQL database).

But what I also want is for the applet to have several input boxes for for descriptions of the the X and Y axes and
so on where these boxes forms part of the Processing graph object.

I think enabling these boxes in the applet should be straightforward. But is it possible for a form on a webpage to
access the contents of these boxes in the applet so that the contents can be passed to the server when the button on
an HTML form is pressed?

I have tried playing with the <object> code generated in the web page by Processing during Export but without
success. To give an example, this is the sort of thing I've tried within the body of Processing code:

String stringOut = ("This is a message");

String getStringOut() {
               return stringOut;
       }

With code like this in the web pages:

document.write(document.applets[0].getStringOut());
document.write(document.objects[0].getStringOut());

Does anybody know where I'm going wrong or can they advise alternatives? Or am I trying something impossible?

Thanks

Martin O'Shea.
Re: Saving settings from a Processing object / app
Reply #1 - Nov 27th, 2008, 5:09pm
 
See using the <embed> tag over <object> to, replies #3, #5, #7...

I was precisely thinking of experimenting more on Web form <-> applet interaction, as it is an interesting, lightweight alternative to the GUI libraries of Processing. The latter have their usefulness, of course, but using HTML forms allows interesting stuff like pasting, using browser's spellchecking, etc.

Beside the call of JS functions shown above, you can access the Dom itself:

JSObject win = (JSObject) JSObject.getWindow(this);
JSObject doc = (JSObject) win.getMember("document");
JSObject loc = (JSObject) doc.getMember("location");
String href = (String) loc.getMember("href");

// Access a function object!
JSObject fun = (JSObject) win.getMember("DumbTest");

And so on.
Re: Saving settings from a Processing object / app
Reply #2 - Nov 27th, 2008, 5:39pm
 
PhiLho

Thanks for the reply. I suppose I could use Javascript; I'm not overly sure about DOM but it's early days yet.

If I may ask one other question, if a user has an applet running in a web page showing a graph, do you know if it's possible to save an image of the current graph as a .png, .gif etc file to the server?

Thanks

Martin O'Shea.
Re: Saving settings from a Processing object / app
Reply #3 - Nov 28th, 2008, 12:22am
 
There is a hack about this, and I made a more secure version in Re: save to web --- image export (yes, I tend to cite myself... Smiley).
Re: Saving settings from a Processing object / app
Reply #4 - Nov 28th, 2008, 12:34am
 
PhiLho

I've just gotten Processing working when the mouse is clicked to call a Javascript method to put out an 'alert' message. It's the 'other way around' from what I have seen before where you can use Javascript to access methods in the applet's code.

Many, many thanks for your help with this and the details about the 'hack' for saving an image to the server.

Martin O'Shea.
Page Index Toggle Pages: 1