Hi John

request = tool.init() called once per request
session = tool.init() called once per session
global  = tool.init() called once per startup of turbine

so your vector will be initialized every time you call a screen,

Uwe

-----Urspr�ngliche Nachricht-----
Von: John Harris [mailto:[EMAIL PROTECTED]]
Gesendet am: Samstag, 4. Mai 2002 21:49
An: [EMAIL PROTECTED]
Betreff: RE: Passing objects to context

I need a little more help on the Request tool. I created a
tool.request.mytool and had screen1.java place a vector object into $mytool.
screen1.vm accessed it fine, but so did screen2.vm.

I used explorer to test this, then opened up netscape and went straight to
screen2.vm and was able to access the same vector I placed into mytool.

I know I'm missing something somewhere, but how is tool.request different
from tool.global? I only want $mytool.myvector available to the current
user. I know tool.session would work for something like this, but wanted to
figure out tool.request.

Thanks for any help on this one.

John

>>> [EMAIL PROTECTED] 05/03/02 11:25AM >>>
To start, take a look at the pull service documentation, 
<http://jakarta.apache.org/turbine/turbine-2/services/pull-service.html>.

It lays out the differences between request-based and session-based pull
tools.  

Here are some differences in a nutshell: 

A session tool's init(Object) method is passed a User object and the Request
tool is passed a RunData object.

session tools are stored in the User's temp HashMap while Request tools are
per request only.  

User pull tools are initialized once per user session or if the User within
the session is changed.  As I stated above, all session tools are stored in
the User's temp HashMap (User.getTemp() and User.setTemp()).

Once you have written one pull tool, you will realize how obscenely simple
they are to create and how powerful they are to use!


hth,
scott



> -----Original Message-----
> From: akmal Sarhan [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, May 03, 2002 10:25 AM
> To: [EMAIL PROTECTED] 
> Subject: RE: Passing objects to context
> 
> 
> Hi Scott,
> can you give an example code.
> 
> Akmal
> 
> 
> >From: "Weaver, Scott" <[EMAIL PROTECTED]>
> >Reply-To: "Turbine Users List" <[EMAIL PROTECTED]>
> >To: 'Turbine Users List' <[EMAIL PROTECTED]>
> >Subject: RE: Passing objects to context
> >Date: Fri, 3 May 2002 09:20:53 -0400
> >
> >Another, possibly more Turbine-esque, way to acheive this is to use a
> >session pull tool.  This is a little easier than using a the 
> http session
> >since the pull tool is always automatically added to the 
> context.  This way
> >you don't have to worry about adding to the http session or 
> to the context.
> >
> >scott
> >
> > > -----Original Message-----
> > > From: Fabio Daprile [mailto:[EMAIL PROTECTED]] 
> > > Sent: Friday, May 03, 2002 5:10 AM
> > > To: Turbine Users List
> > > Subject: Re: Passing objects to context
> > >
> > >
> > > Hello John,
> > >
> > > Another way to pass objects from a screen to another is to
> > > store objects
> > > in the session object.
> > > hereafter an example:
> > >
> > > in the Java code:
> > >
> > > ParameterParser _formParams;
> > > HttpSession _session;
> > >
> > > _formParams = data.getParameters();
> > > _session = data.getSession();
> > >
> > > _queueId = _formParams.getInt("Queue");
> > > _session.setAttribute("QueueId",Integer.toString(_queueId));
> > >
> > > in the VM:
> > >
> > > $data.getSession().getAttribute("QueueId")
> > >
> > > hope this can help you.
> > >
> > > regards.
> > >
> > > ---
> > > Fabio Daprile
> > >
> > > Wu"rth-Phoenix Srl
> > > Via Kravogl 4, I-39100 Bolzano
> > > Tel: +39 0471/564111 - (direct 564070)
> > > Fax: +39 0471/564122
> > >
> > > mailto:[EMAIL PROTECTED] 
> > > http://www.wuerth-phoenix.com 
> > > http://www.wuerth.com 
> > >
> > >
> > > John Harris wrote:
> > >
> > > >Please forgive the simplicity of the question, but I'm
> > > trying to learn and become accustomed to turbine. Any help is
> > > greatly appreciated.
> > > >
> > > >How can I carry a vector holding the result of a doSelect
> > > query from one screen to another? For example, if I have the
> > > following code for screen1.vm, with its associated
> > > screen1.java - after the user selects the id, how can
> > > testAction.java grab $resultSet from screen1.vm.
> > > >
> > > >http://localhost/appname/servlet/appname/template/screen1.vm 
> > > >
> > > ><form action="$link.setAction("testAction")">
> > > ><select name="testSelect" id="testSelect">
> > > >#foreach $record in $resultSet
> > > ><option value=$record.id>$record.name</option>
> > > >#end
> > > ></select>
> > > ></form>
> > > > -------------------------------------------------------
> > > >public class screen1 extends VelocityScreen {
> > > >  public void doBuildTemplate(Rundata data, Context context)
> > > throws Exception {
> > > >
> > > >    Criteria crit = new Criteria();
> > > >    crit.add(TablePeer.TYPE, 1);
> > > >    Vector ResultSet = TablePeer.doSelect(crit);
> > > >    context.put("resultSet", ResultSet);
> > > >  }
> > > >}
> > > >
> > > >- John Harris
> > > >
> > > >
> > > >--
> > > >To unsubscribe, e-mail:
> ><mailto:[EMAIL PROTECTED]>
> > >For additional commands, e-mail:
> ><mailto:[EMAIL PROTECTED]>
> > >
> > >
> > >
> >
> >
> >
> >--
> >To unsubscribe, e-mail:
> ><mailto:[EMAIL PROTECTED]>
> >For additional commands, e-mail:
> ><mailto:[EMAIL PROTECTED]>
> 
> 
> _________________________________________________________________
> Send and receive Hotmail on your mobile device: http://mobile.msn.com 
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to