« Return to Thread: Re: Java object scopes: using same object in multiplefunctions

Re: Java object scopes: using same object in multiplefunctions

by David Marginian-2 :: Rate this Message:

Reply to Author | View in Thread

You need to add the scope attribute on the creator element not the param
like I showed you (and the docs indicate):
<create creator="new" javascript="VigraMain" scope="session">



Original Message:
-----------------
From: Daniel Gresh dgresh@...
Date: Thu, 17 Apr 2008 12:48:45 -0400
To: users@...
Subject: Re: [dwr-user] Java object scopes: using same object in
multiplefunctions


Hi,

I tried adding the session scope on the creator:

    <allow>
        <create creator="new" javascript="VigraMain">
            <param name="class" value="dng.vigravision.VigraMain"
scope="session" />
        </create>
    </allow>

However, I seem to be getting the same problem. I've tried using my java
outside of the context of the web page to make sure it wasn't an issue
with that, and it seems to work fine, without any NPEs or errors of any
sort.

Is there anything I need to specify in the html file itself about the
scope or session? Will posting any code I have help?

Thanks for the reply,
Dan

david@... wrote:
> Session creator?  There is no session creator.
> http://getahead.org/dwr/server/dwrxml/creators
>
> What you want is to specify the scope attribute on your creator to
session.

>
> Try:
> <create creator="new" javascript="VigraMain" scope="session">
>
>
>
> Original Message:
> -----------------
> From: Daniel Gresh dgresh@...
> Date: Thu, 17 Apr 2008 11:46:38 -0400
> To: users@...
> Subject: [dwr-user] Java object scopes: using same object in multiple
> functions
>
>
> Hi,
>
> I have two javascript functions that both use the same java class,
> VigraMain. I need each of the functions to use the same instance of
> VigraMain, but this does not seem to happen, as I get some
> NullPointerExceptions that would only occur if the object instances are
> not the same.
>
> In my dwr.xml file I declare the creator for the class to be:
>
>     <allow>
>         <create creator="new" javascript="VigraMain">
>             <param name="class" value="dng.vigravision.VigraMain" />
>         </create>
>     </allow>
>
> I thought using the "session" creator would fix the problem, but when I
> use that creator, nothing seems to happen.
>
> Is there anyway to store the class object in a javascript variable or
> session or something so it can be used in both functions?
>
> To show what I have specifically, I have two functions that look like
this:

>
>             function startVigraService() {
>                 var cameraName = dwr.util.getValue('cameraName1');
>                 var iceGridLocator = dwr.util.getValue('iceGridLocator');
>                 var adapterId = dwr.util.getValue('adapterId');
>                 VigraMain.startCameraWeb(cameraName, iceGridLocator,
> adapterId, vigraServiceStarted());
>             }
>
>             function captureVigraImage() {
>                 var cameraName = dwr.util.getValue('cameraName2');
>                 var frameNumber = dwr.util.getValue('channelNumber');
>                 VigraMain.uploadImage(cameraName, frameNumber,
> vigraImageCaptured());
>             }
>
> As you can see, I want each VigraMain object to be the same as the other
> one, but this does not seem to happen, and my second function throws
> some NPEs.
>
> I'm pretty new to the whole web programming thing, sessions, beans, and
> all that jazz. Is there anything I'm missing that would allow me to do
this?
>
> Thanks,
> Dan
>
>  

--
Dan Gresh
Lab Technician -- EP Controls
Laboratory for Laser Energetics
(585) 275-4819


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...



--------------------------------------------------------------------
myhosting.com - Premium Microsoft® Windows® and Linux web and application
hosting - http://link.myhosting.com/myhosting



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

 « Return to Thread: Re: Java object scopes: using same object in multiplefunctions