You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by John Harris <Jo...@nurs.utah.edu> on 2002/05/03 10:16:33 UTC

Passing objects to context

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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Passing objects to context

Posted by Fabio Daprile <fa...@wuerth.it>.
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:fabio.daprile@wuerth-phoenix.com
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:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>