You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Tom Bednarz <li...@bednarz.ch> on 2004/03/22 16:28:48 UTC

HttpServletRequest - Velocity LinkTool ---> I am confused!

Hi,

I have the following scenario:

A user fills in a HTML form to search for something. The result is presented as a table. The servlet performing the search (Struts Action Servlet) generates a Vector of Hashtable objects. Every found record is stored in a Hashtable where the fieldname is the key.

The user can make a selection in the result table by clicking on a link. This selection is passed to another Action Servlet.

Question:

Is there a way to pass the Hashtable object AS HASHTABLE OBJECT (not as String) to the servlet? I tried using the linktool as shown below::

         <TD class=datalightAlignRight colspan><a class="command" href=$link.setURI("$appRoot/requestGroupMembership.do").addQueryData("Record", $record)>Request access</a></TD>

$record is a Hashtable
Instead of adding n parameters (n is the size of the hashtable) I would like to pass only one parameter: the entire hashtable

If I look at the Parameter "Record" in the debugger (debugging the servlet) I see a String containing Name / Value pairs such as MyName1=MyValue1, MyName2=MyValue2, .... 

Any solution?

Thomas

Re: HttpServletRequest - Velocity LinkTool ---> I am confused!

Posted by Tom Bednarz <li...@bednarz.ch>.
Mike,

Thanks for your help. See my anwers below.

----- Original Message ----- 
From: "Mike Curwen" <gb...@gb-im.com>
To: "'Velocity Users List'" <ve...@jakarta.apache.org>
Sent: Monday, March 22, 2004 4:57 PM
Subject: RE: HttpServletRequest - Velocity LinkTool ---> I am confused!


> You can't do it.  Let's see if I can guess why you're trying to do
> this...  You've figured that since you went to all the work of creating
> a Vector of all the results of your search, and because that Vector
> contains full-fledged objects (Hashtables)... it would be a waste to
> have to 'get' them again from a database, when you click on a result
> link, to show the 'details'.  Is that about right?
>
Almost..... I simply hate inefficient, memory consuming code. When writing
server code or Swing GUIs I hold data only ONCE in memory (usually having
more or less complex datastructures such as lists, sets, maps etc) and have
lots of references to it (in C++ we call them pointers...). With such
datastructures searching and manipulating the data is fast and efficient. A
little bit more problematic is to find the right moment to release all the
memory. In case of Java it is the job of the VM....., in C++ the one of the
programmer.

> If so, why not have your search return *only* enough detail to show a
> reasonable listing in the search results (title, description, primary
> key), instead of the 'full' object.  Also, you might consider using a
> List.  Then y our second step needs only the primary key, and it will do
> the job of retrieving the 'full fledged' object.

Because the result table is a table of tables. It shows a lot of information
so the user can decide which one to select. It is probably easier to pass
only those information to the next action servlet I need for the next
processing step. HTTP is limited (stupid ping-pong protocoll) but has other
advantages.
>
> Or is that not what you're wanting?
>

Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


RE: HttpServletRequest - Velocity LinkTool ---> I am confused!

Posted by Mike Curwen <gb...@gb-im.com>.
You can't do it.  Let's see if I can guess why you're trying to do
this...  You've figured that since you went to all the work of creating
a Vector of all the results of your search, and because that Vector
contains full-fledged objects (Hashtables)... it would be a waste to
have to 'get' them again from a database, when you click on a result
link, to show the 'details'.  Is that about right?
 
If so, why not have your search return *only* enough detail to show a
reasonable listing in the search results (title, description, primary
key), instead of the 'full' object.  Also, you might consider using a
List.  Then y our second step needs only the primary key, and it will do
the job of retrieving the 'full fledged' object.
 
Or is that not what you're wanting?

> -----Original Message-----
> From: Tom Bednarz [mailto:list@bednarz.ch] 
> Sent: Monday, March 22, 2004 9:29 AM
> To: velocity-user@jakarta.apache.org
> Subject: HttpServletRequest - Velocity LinkTool ---> I am confused!
> 
> 
> Hi,
> 
> I have the following scenario:
> 
> A user fills in a HTML form to search for something. The 
> result is presented as a table. The servlet performing the 
> search (Struts Action Servlet) generates a Vector of 
> Hashtable objects. Every found record is stored in a 
> Hashtable where the fieldname is the key.
> 
> The user can make a selection in the result table by clicking 
> on a link. This selection is passed to another Action Servlet.
> 
> Question:
> 
> Is there a way to pass the Hashtable object AS HASHTABLE 
> OBJECT (not as String) to the servlet? I tried using the 
> linktool as shown below::
> 
>          <TD class=datalightAlignRight colspan><a 
> class="command" 
> href=$link.setURI("$appRoot/requestGroupMembership.do").addQue
> ryData("Record", $record)>Request access</a></TD>
> 
> $record is a Hashtable
> Instead of adding n parameters (n is the size of the 
> hashtable) I would like to pass only one parameter: the 
> entire hashtable
> 
> If I look at the Parameter "Record" in the debugger 
> (debugging the servlet) I see a String containing Name / 
> Value pairs such as MyName1=MyValue1, MyName2=MyValue2, .... 
> 
> Any solution?
> 
> Thomas
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org