On Wed, May 13, 2009 at 11:22 AM, marino99 <[email protected]> wrote:
>
> Hi again,
>
> doesn't anybody have a solution / clue for me? Or is it even impossible to
> have one instance of a Java class and use it the way instances are usually
> used? Maybe I didn't make my point clear enough, so here's the code I used
> for testing:
>
I don't know about the Java backend but I suspect you need to implement
persistence. In the PHP backend, each request to the backend is its own
"instance" so if one wanted to be able to set a value and retrieve it in a
separate request, that value would have to be saved someplace on the server
(e.g. in a database).
Consider this: With what you're trying to do, what happens if a different
user loads the same application? When they issue the get() call, does it
return "default" or the value set by your instance of the application? The
backend will need to be implemented to know which you want. It may need to
track per-session data, or per-user data (if you implement some sort of
log-in), or global data (all users get values set by other users).
Derrell
> var button1 = new qx.ui.form.Button("setTestString", "rpctest/test.png");
> var doc = this.getRoot();
> doc.add(button1, {left: 100, top: 50});
> var rpc = new qx.io.remote.Rpc("http://localhost:8080/rpctest/.qxrpc",
> "rpc.RPCTest");
> rpc.setCrossDomain(true);
> var handler1 = function(result, exc) {
> if (exc == null) {
> alert("Result of handler1: " + result);
> } else {
> alert("Exception during handler1 async call: " + exc);
> }
> };
> button1.addListener("execute", function(e) {
> rpc.callAsync(handler1, "setTestString", "test it");
> });
>
> var button2 = new qx.ui.form.Button("getTestString", "rpctest/test.png");
> doc.add(button2, {left: 100, top: 150});
> var handler2 = function(result, exc) {
> if (exc == null) {
> alert("Result of handler2: " + result);
> } else {
> alert("Exception during handler2 async call: " + exc);
> }
> };
> button2.addListener("execute", function(e) {
> var str = rpc.callAsync(handler2, "getTestString");
> });
>
>
> And this is the Java class RPCTest:
>
> public class RPCTest implements RemoteService {
> int n;
> String testString = "default";
>
> public String getTestString() throws RemoteServiceException {
> return testString;
> }
>
> public void setTestString(String s) throws RemoteServiceException {
> testString = s;
> }
> }
>
> Both methods work for themselves, but when I call setTestString() by
> clicking button1 and then getTestString() by clicking button2 I get the
> String "default" instead of "test it" because a new instance is created
> each
> time. How can I manage to reuse the instance that has been created by
> clicking button1?
>
>
>
> marino99 wrote:
> >
> > Hello,
> >
> > I have a problem concerning RPC with Java. I use Apache Tomcat as a
> server
> > on my local system. Async calls to Java classes work fine, but I would
> > like to use one instance of a Java class again. I don't know if that's at
> > all possible, but hope so.
> > In more detail: I would like to be able to call the method setSomething()
> > in the Java class and get the value I just set by calling getSomething().
> > At the moment, a new instance is generated everytime I call any method.
> > I think it's got something to do with Tomcat. Maybe I need to change any
> > settings, e.g. web.xml?
> >
> > Thanks for your help!
> >
>
> --
> View this message in context:
> http://www.nabble.com/Java-RPC-and-instances-of-Java-classes-tp23447440p23524026.html
> Sent from the qooxdoo-devel mailing list archive at Nabble.com.
>
>
>
> ------------------------------------------------------------------------------
> The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
> production scanning environment may not be a perfect world - but thanks to
> Kodak, there's a perfect scanner to get the job done! With the NEW KODAK
> i700
> Series Scanner you'll get full speed at 300 dpi even with all image
> processing features enabled. http://p.sf.net/sfu/kodak-com
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel